Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax for Passing a session variable to Oracle as a parameter

Status
Not open for further replies.

ajacode

Technical User
Aug 21, 2002
66
US
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
++++++++++++++++++++++++++++++
Code:
<%@ Language=VBScript %>
<% Response.Buffer = True %>
<script id=&quot;DebugDirectives&quot; runat=&quot;server&quot; language=&quot;javascript&quot;>
// Set these to true to enable debugging or tracing
@set @debug=true
@set @trace=true
</script>
<script ID=&quot;serverEventHandlersVBS&quot; Language=&quot;vbscript&quot; RUNAT=&quot;SERVER&quot;>
dim usrLoginID

SUB usrStartFrm_onenter()
	
	var usrLoginID = Session(&quot;LoginID&quot;)

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

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

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

Sub Button1_onclick()				
				If Session(&quot;BusSeg&quot;) = &quot;&quot;  Then
					Session(&quot;BusSeg&quot;) = (Listbox1.getValue ()) 
				End If	
					Recordset1.open() 
		
End Sub

Sub Listbox1_onchange()
				
			Session(&quot;BusSeg&quot;) = (Listbox1.getValue ())
			
			Button1.show
			Response.Write Session(&quot;BusSeg&quot;)		
End Sub


%>
<!--#INCLUDE FILE=&quot;../_ScriptLibrary/Recordset.ASP&quot;-->
<SCRIPT LANGUAGE=&quot;JavaScript&quot; RUNAT=&quot;server&quot;>
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 _rsLstBusSeg_ctor()
{
	CreateRecordset('rsLstBusSeg', _initrsLstBusSeg, null);
}
function _rsLstBusSeg_dtor()
{
	rsLstBusSeg._preserveState();
	thisPage.setState('pb_rsLstBusSeg', rsLstBusSeg.getBookmark());
}
</SCRIPT>

</head>
<body>

<table border=&quot;0&quot; Align=&quot;center&quot; width=&quot;100%&quot; valign=&quot;top&quot;>
  
<tr> <td Width=&quot;10%&quot; valign=&quot;top&quot;>
Pick Your Assigned Bus Segment
</td>
</tr>  <tr>
<td Valign=&quot;top&quot;>
 
I have bolded the part with the problem..

Replace this line:

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';


with:

cmdTmp.CommandText = &quot;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 = \'&quot; + varLoginID + &quot;\') ORDER BY B.BUSINESSSEGMENTNAME&quot;;


Hope this helps..

Gorkem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top