473,386 Members | 1,758 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,386 software developers and data experts.

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


"Mark C. Stock" <mcstockX@Xenquery .comwrote in message news:...
|
| "Berend" <Be**************@evatone.comwrote 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
|
|

here's a reference to the using the TABLE and CAST operators/keywords to
feed a the contents of a multi-valued variable to a SQL statement (thanks to
another post by dan morgan) http://www.psoug.org/reference/conditions.html

(forget about the temp table and explicit ORs suggestions)

-- mcs
Jun 27 '08 #1
0 2538

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...
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...
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...
4
by: Mike Dinnis | last post by:
Hi, I've been working through a number of turorials to try to learn more about retrieving data from a SQL database. I think i've mastered techniques where i create a sql string in the page and...
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: 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....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.