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!

How to pass parameter to cursor (which uses IN string)

110252Dec 6 2001
I wanted to pass parameter to CURSOR in stored procedure. In
the cursor selection WHERE clause I would like to use IN
string. When the parameter string has one ID such as E0001 it
works fine but when parameter string has multiple IDs such as
E0001, E0002, E0003 it does not work. I used single quotes
across IDs as 'E0001', E0002', 'E0003' it still does not work.
All the more if I have single ID with quotes across such
as 'E0001' does not work. I am calling this stored procedure
from ASP page. Can I pass multiple IDs to IN string of cursor
selection WHERE clause?

I am enclosing code snippet.


PROCEDURE SP_MYSTOREDPROCEDURE
(empids IN VARCHAR2, errnum OUT VARCHAR2, errdesc OUT VARCHAR2)
IS

CURSOR empcur IS
SELECT emp_id, emp_first_name, emp_last_name
FROM emp
WHERE emp_id IN (empids);

<%
Dim myids
'myids is a in a loop on previous ASP page and
using the following code to concatenates ids
myids=myids & "'" & <%= previousidread %> & "', "
myids=myids & "'END'"
'an END is added at the end to mark end of the
string
'by the end of the loop myids might have value
as 'E0001', 'E0002', 'END'

Dim Conn, Cmd, Rs
Set Conn = Server.CreateObject
("ADODB.Connection")
Set Cmd = Server.CreateObject("ADODB.Command")
Set Rs = Server.CreateObject("ADODB.RecordSet")
Dim strConnection
strConnection = Application("g_DSN_MYDSN")
Conn.Open strConnection
Cmd.ActiveConnection = Conn
Cmd.CommandType = adCmdStoredProc
Cmd.CommandText = "Pkg_Mypackage.Sp_MyStoredProc"
Cmd.Parameters.Append Cmd.CreateParameter
("myempids", adVarChar, adParamInput, 4000, myids)
Cmd.Parameters.Append Cmd.CreateParameter
("myerrnum", adVarChar, adParamOutput, 10)
Cmd.Parameters.Append Cmd.CreateParameter
("myerrdesc", adVarChar, adParamOutput, 100)
Set Rs = Cmd.Execute
%>



Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 4 2002
Added on Dec 6 2001
6 comments
655 views