Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

ASP (Javascript) syntax to pass varchar variable to ORACLE 8i

320880Aug 29 2002
In a runtime SQL statment I am trying to pass the session variable to Oracle.

I can pass a hard coded literal but all my attempts at variables retursn a null data set..

Here is the Code I have tried to no real success except for hardcoding:
+++++++++++++++++++
( L.LOGINID = \'<% ajLoginID %>\')

REturns Null Data Set

++++++++++++++++++++++++++++++++++

( L.LOGINID = \'ajgrasso\')

Returns a Data Set (at least we know Oracle is Working)
++++++++++++++++++++++++++++++++++
( L.LOGINID = \'<% =ajLoginID %>\')

Returns a null Data Set

I am attaching the ASP page code and the specific code for the question regarding passing the variable to the Oracle DB


This One Does NOT work
++++++++++++++++++++++++++++++


<%@ Language=VBScript %>
<% Response.Buffer = True %>
<script id="DebugDirectives" runat="server" language="javascript">
// Set these to true to enable debugging or tracing
@set @debug=true
@set @trace=true
</script>
<script ID="serverEventHandlersVBS" Language="vbscript" RUNAT="SERVER">
dim usrLoginID

SUB usrStartFrm_onenter()

var usrLoginID = Session("LoginID")

End SUB
</script>

<% ' VI 6.0 Scripting Object Model Enabled %>
<!--#include file="../_ScriptLibrary/pm.asp"-->
<% if StartPageProcessing() Then Response.End() %>
<form name="thisForm" METHOD="post">
<html>
<head>
<meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">

<%
'THESE ALL PRODUCE THE USER LOGIN NAME PROPERLY so I know the variable has a value
dim varLoginID

varLoginID=Session("LoginID")
Response.Write (usrLoginID) & "usr"
Response.Write (varLoginID) & "Var"
Response.Write (Session("LoginID")) & "Session"

Sub Button1_onclick()
If Session("BusSeg") = "" Then
Session("BusSeg") = (Listbox1.getValue ())
End If
Recordset1.open()

End Sub

Sub Listbox1_onchange()

Session("BusSeg") = (Listbox1.getValue ())

Button1.show
Response.Write Session("BusSeg")
End Sub


%>
<!--#INCLUDE FILE="../_ScriptLibrary/Recordset.ASP"-->
<SCRIPT LANGUAGE="JavaScript" RUNAT="server">
function _initrsLstBusSeg()
{
var DBConn = Server.CreateObject('ADODB.Connection');
DBConn.ConnectionTimeout = Application('Connection1_ConnectionTimeout');
DBConn.CommandTimeout = Application('Connection1_CommandTimeout');
DBConn.CursorLocation = Application('Connection1_CursorLocation');
DBConn.Open(Application('Connection1_ConnectionString'), Application('Connection1_RuntimeUserName'), Application('Connection1_RuntimePassword'));
var cmdTmp = Server.CreateObject('ADODB.Command');
var rsTmp = Server.CreateObject('ADODB.Recordset');
cmdTmp.ActiveConnection = DBConn;
rsTmp.Source = cmdTmp;
cmdTmp.CommandType = 1;
cmdTmp.CommandTimeout = 30;
cmdTmp.CommandText = 'SELECT DISTINCT L.LOGINID, B.BUSINESSSEGMENTNAME FROM SODA.ASSIGNMENTS_TB A, SODA.LOGINS_TB L, SODA.BUSSEGMENT_TB B WHERE A.FK_LOGIN_NO = L.LOGIN_NO AND A.FK_BUSSEGID = B.BUSSEGID AND
L.LOGINID = \'<% varLoginID %>\') ORDER BY B.BUSINESSSEGMENTNAME';
rsTmp.CacheSize = 100;
rsTmp.CursorType = 3;
rsTmp.CursorLocation = 3;
rsTmp.LockType = 1;
rsLstBusSeg.setRecordSource(rsTmp);
rsLstBusSeg.open();
if (thisPage.getState('pb_rsLstBusSeg') != null)
rsLstBusSeg.setBookmark(thisPage.getState('pb_rsLstBusSeg'));
}
function rsLstBusSegctor()
{
CreateRecordset('rsLstBusSeg', _initrsLstBusSeg, null);
}
function rsLstBusSegdtor()
{
rsLstBusSeg._preserveState();
thisPage.setState('pb_rsLstBusSeg', rsLstBusSeg.getBookmark());
}
</SCRIPT>

</head>
<body>

<table border="0" Align="center" width="100%" valign="top">

<tr> <td Width="10%" valign="top">
Pick Your Assigned Bus Segment
</td>
</tr> <tr>
<td Valign="top">

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 26 2002
Added on Aug 29 2002
2 comments
1,202 views