Re: getting Multiple resultsets in java using stored procedure in MS SQL Server 2000
- From: Joe Weinstein <joeNOSPAM@xxxxxxx>
- Date: Sat, 04 Mar 2006 08:24:17 -0800
anil wrote:
Hi Joe and Subhash, thank you for your replies.
I am using a comma seperated value string as the parameter viz
'aaa','bbb','ccc'
variable defined in sp is varchar(4000).
the query used in the procedure is a select statement with an IN clause
eg. select field_name from table where field_name IN (<csv string>)
just executing the query with a csv string as parameter works fine, but
the procedure fails.
I found out that if the parameter is a single string 'aaa', i'm getting
the resultset with records, but if its a csv string, its returning an
empty resultset.
I tried printing out the input variable in the sp and it looks
fine...it prints viz 'aaa','bbb','ccc'
did any of you came across this problem, any pointers would help.
Thank you.
-Anil
Ok, well that's your problem. You have one variable marker in the SQL,
but you want the DBMS to accept it as a list of parameter values.
That won't fly. Parameter substitution is really only single data
values. If the procedure is defined to take three parameters,
you will have to put a '?' for every value, eg:
cStmt = conn.prepareCall("{ call spXXX (?,?,?)}");
cStmt.setString(1, "aaa");
cStmt.setString(1, "bbb");
cStmt.setString(1, "ccc");
etc.
HTH,
Joe Weinstein at BEA Systems
Joe Weinstein wrote:
anil wrote:
I have a stored procedure with multiple (two) queries in MS-SQL 2000
Server,
I'm trying to get the resultset in java
like
cStmt = conn.prepareCall("{ call spXXX (?)}");
cStmt.setString(1, val);
What is the variable defined as in the procedure?
What is the column type that the variable is
used to compare to? I suspect you're trying to rely
on the DBMS doing implicit conversion, which it will
do for fresh SQL, but not parameters.
Joe Weinstein at BEA Systems.
.
- Follow-Ups:
- References:
- Prev by Date: Re: getting Multiple resultsets in java using stored procedure in MS SQL Server 2000
- Next by Date: Re: getting Multiple resultsets in java using stored procedure in MS SQL Server 2000
- Previous by thread: Re: getting Multiple resultsets in java using stored procedure in MS SQL Server 2000
- Next by thread: Re: getting Multiple resultsets in java using stored procedure in MS SQL Server 2000
- Index(es):
Relevant Pages
|