473,732 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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


"Mark C. Stock" <mcstockX@Xenqu ery .comwrote in message news:...
|
| "Berend" <Be************ **@evatone.comw rote in message
| news:bd******** *************** ***@posting.goo gle.com...
| | 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_s pec_test (
| | p_eva_product_h eader_ids IN VARCHAR2,
| | cur_spec_cd IN OUT
| | sysadm.eva_pkg_ wrk014_spec_tes t.ref_spec_spec _cd
| | )
| | AS
| | BEGIN
| | OPEN cur_spec_cd
| | FOR
| | SELECT *
| | FROM sysadm.eva_prod uct_header eph
| | WHERE eph.eva_product _header_id in (p_eva_product_ header_ids);
| | END eva_sp_wrk014_s pec_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_h eader_ids, cDelimiter ||
| eph.eva_product _header_id || cDelimiter) 0
|
| (the p_eva_product_h eader_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 2566

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

Similar topics

0
5441
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 this error message: "The Error Message was: Error detected by database DLL.from: Crystal Reports ActiveX Designer". What am I doing wrong in the SubReport section below and how do I properly pass in sproc params to the subreport? Thanks. ...
1
11809
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 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
4
2192
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 type of parameter is passed in, the where clause would use "LIKE" operator. For example, "Select * from Main where like @Serial. All other types will use "=" operator. For example, "Select * from Main where MAKE = @Make and Type = @type". How...
10
125458
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 : set @pCode='A1','A2','A3' but get an error : Incorrect syntax near ','
39
7659
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 indicate: a) That I don't know enough b) Passing arguments by ref is bad
4
3001
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 pass it to the Db and retrieveing data from a stored procedure, but I can't get the hang of parameters. I have a method where I can get the parameters passed to the sp but it doesn't want to return any results. Here's a copy of my code:
11
8128
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 number) which is the last line of the following sub routine: ' procedure modifies elements of array and assigns ' new reference (note ByVal) Sub FirstDouble(ByVal array As Integer()) Dim i As Integer
4
2758
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 to a stored procedure on the details2.aspx page. I can successfully pass the values from the listbox control to a
1
9717
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. I want to use these values in where clause of select statement using IN. I can't use prepared statements because queries written in stored procedure are very complex.
0
8774
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9307
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9235
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9181
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8186
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.