Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle passsing comma seperated values as parameter and where condition

supersenOct 17 2023

HI

i have requirement to to pass comma seperated value as parameter and also in where clause of query. can i able to achieve without dynamic query.

passing parameter will be like 601,602,603,604,605,606,609,610.

for example

create table test1 as
select rownum rn, TO_NUMBER(column_value) data_value FROM
XMLTABLE ( '601, 602, 603, 604,605, 606, 609, 610' ) order by 2 ;

SELECT * from test1

1 601
2 602
3 603
4 604
5 605
6 606
7 609
8 610

i want to list out the records by passing values as 601, 602, 603, 604,605, 606, 609, 610

declare
dfid number;
cursor c1 is select rn,data_value
from test1
where data_value in ( dfid);
begin
select listagg(data_value,',') within group ( order by rn)
--into dfid
from test1 ;
for c1_rec in c1 loop
dbms_output.put_line(c1_rec.rn||','||c1_rec.data_value);
end loop;
end;

is it possible without dynamic query? because same block i am going to use for almost 25 times. by simply passing these parameters i can reduce the code

Kindly help

Supersen

This post has been answered by Paulzip on Oct 17 2023
Jump to Answer
Comments
Post Details
Added on Oct 17 2023
7 comments
1,273 views