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!

having multiple parameters in single DEFINE statement in sql plus

Uday_NNov 27 2020

Hi All,
I am writing a script which should have multiple parameters defined in the script itself and it should not be allowed while doing a join . When i give single value query get executed but when i give multiple values seperated by commas it throws error 'invalid multiple arguments' .
Table :
create table tab1 (col1 number ,col2 number);
create table tab2 (col1 number , col3 number );
values :
insert into tab1 values (1,11) ;
insert into tab1 values (2,21) ;
insert into tab1 values (3,31);

insert into tab2 values (1,11);
insert into tab2 values (2,21) ;
insert into tab2 values (3,31) ;

My script :
SET echo OFF ver OFF pages 0 trimspool ON feed OFF und OFF;
DEFINE invalid_value = '2,3';
SET term OFF;
SET VERIFY OFF;
SET linesize 30000
SET WRAP OFF
prompt "col1","col2"
select
'"'
||"Col1"
||'","'
||"Col2"
from
(
select a.* from tab1 a , tab2 b where a.col1 = b.col1
and a.col1 != &invalid_value ) ;
spool off;
exit ;
/

When i execute the Query with single value in DEFINED I am able to get output but if i execute with multiple values say '2,3' then i am getting an error . Is there any way to to pass multiple values in single DEFINE statement .

Regards,
Uday

This post has been answered by Solomon Yakobson on Nov 27 2020
Jump to Answer
Comments
Post Details
Added on Nov 27 2020
4 comments
2,728 views