473,378 Members | 1,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Passing multi values into an in clause via a parameter in a store procedure

I am trying to pass multi values into a where clause with an in clause
in a store procedure to use in a Crystal report. This can change
depending on the user. Maybe there is another way to pass multi
values.
CREATE OR REPLACE PROCEDURE eva_sp_wrk014_spec_test (
p_eva_product_header_ids IN VARCHAR2,
cur_spec_cd IN OUT
sysadm.eva_pkg_wrk014_spec_test.ref_spec_spec_cd
)
AS
BEGIN
OPEN cur_spec_cd
FOR
SELECT *
FROM sysadm.eva_product_header eph
WHERE eph.eva_product_header_id in (p_eva_product_header_ids);
END eva_sp_wrk014_spec_test;
Jul 19 '05 #1
1 11788

"Berend" <Be**************@evatone.com> wrote in message
news:bd**************************@posting.google.c om...
| I am trying to pass multi values into a where clause with an in clause
| in a store procedure to use in a Crystal report. This can change
| depending on the user. Maybe there is another way to pass multi
| values.
|
|
| CREATE OR REPLACE PROCEDURE eva_sp_wrk014_spec_test (
| p_eva_product_header_ids IN VARCHAR2,
| cur_spec_cd IN OUT
| sysadm.eva_pkg_wrk014_spec_test.ref_spec_spec_cd
| )
| AS
| BEGIN
| OPEN cur_spec_cd
| FOR
| SELECT *
| FROM sysadm.eva_product_header eph
| WHERE eph.eva_product_header_id in (p_eva_product_header_ids);
| END eva_sp_wrk014_spec_test;

the IN clause requires separate values (i.e. a separate bind variable for
each value), and you've got all your values stuffed into one variable, the
equivalent of

WHERE eph.eva_product_header_id in ( '00,01,23,43,09,33' )

which attempts to find the value '00,01,23,43,09,33' not the one of the
individual values

you'll need to rewrite your proc to use dynamic sql, or pull a trick like

WHERE instr( p_eva_product_header_ids, cDelimiter ||
eph.eva_product_header_id || cDelimiter) > 0

(the p_eva_product_header_ids parameter would need to have delimiters
between each value, and at the first and last position) -- not great for
performance if it's the only criteria

other options: write the list of IDs to a temp table (perhaps within the
proc itself) and use a subquery or join to the temp table

i think there's also a way these days to write a proc that returns a rowset
that can be used as a SQL table -- that might be another way to transform
the common separated list of ids into something useful in a non-dynamic SQL
statement

or -- write a bunch of explicit ORs that can handle up to the max number or
IDs you think you'd be searching for, then parse out the IDs into local
variables

-- mcs
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Aaron | last post by:
The following code works fine when previewing a Crystal report using ASP, EXCEPT when it gets to a report using a SubReport and its associated parameters. The whole report just comes up blank with...
4
by: js | last post by:
I have a stored procedure named "processInventory" like the following. Depending on the passed in parameters, I would like to add a WHERE clause for "select" action. For example, if any varchar...
10
by: Resant | last post by:
I have a query : Exec 'Select * From Receiving Where Code In (' + @pCode + ')' @pCode will contain more than one string parameter, eg : A1, A2, A3 How can i write that parameters, I try use :...
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
11
by: John Pass | last post by:
Hi, In the attached example, I do understand that the references are not changed if an array is passed by Val. What I do not understand is the result of line 99 (If one can find this by line...
4
by: Ranginald | last post by:
Hi, I'm having trouble passing a parameter from my default.aspx page to my default2.aspx page. I have values from a query in a list box and the goal is to pass the "catID" from default.aspx...
1
by: Berend | last post by:
I am trying to pass multi values into a where clause with an in clause in a store procedure to use in a Crystal report. This can change depending on the user. Maybe there is another way to pass...
0
by: Mark C. Stock | last post by:
"Mark C. Stock" <mcstockX@Xenquery .comwrote in message news:... | | "Berend" <Berend.Brinkhuis@evatone.comwrote in message | news:bdd9ac20.0401271301.22cdb65e@posting.google.com... | | I am...
1
by: udaypawar | last post by:
Hi All, I have one problem here with mysql stored procedures. I have a list of ids seperated by comma e.g., (" 'A', 'B', 'C' "). I am passing the same to mysql stored procedure as a parameter....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.