Solved

IN operator usage in stored procedure

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

Join & Write a Comment

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to recover a database from a user managed backup

762 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

18 Experts available now in Live!

Get 1:1 Help Now