Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

IN operator usage in stored procedure

Posted on 2006-07-12
3
Medium Priority
?
1,100 Views
Last Modified: 2008-02-26
hi,

I'm developing a simple form which will show some records, user can select more than one record at a time.
Now my query is to how to give all the  selected records (say PK's) in the query which is put up in a stored procedure.
For E.g.

select * from user u where u.Pk in (1,2,3,4)

user will select 1,2,3,4 from front end but how to pass these pk's to the query.

I've tried by giving array but i was not able to.
Please give solution for above or suggest any other way of doing this.

Thanks,
0
Comment
Question by:jeebukarthikeyan
3 Comments
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 17088897
Hello jeebukarthikeyan,

1. one fast solution could be - pass parameter as a string, i.e. "1,2,3,4"
2. transform your select as
PROCEDURE test ( PARAM_ID IN VARCHAR2 ) AS
begin
  execute immediate 'select * from user u where u.Pk in (' || PARAM_ID || ')';
end;

HTH

I
0
 
LVL 13

Author Comment

by:jeebukarthikeyan
ID: 17088993
Thanks mate,

But I was looking for a solution where I need not go for a dynamic query.

Thanks
0
 
LVL 14

Accepted Solution

by:
GGuzdziol earned 750 total points
ID: 17089006
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
Suggested Courses

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question