Solved

IN operator usage in stored procedure

Posted on 2006-07-12
3
1,086 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

Title # Comments Views Activity
Oracle Pivot 2 43
Oracle DATE Column Space 11 63
dates - loop 12 57
Oracle Public Synonyms and Privileges 2 51
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…
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 connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
Via a live example, show how to take different types of Oracle backups using RMAN.

895 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now