Solved

IN operator usage in stored procedure

Posted on 2006-07-12
3
1,090 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 250 total points
ID: 17089006
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

830 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