Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Passing bind variable from pl/sql to sql block.
Hi there,
I have 2 questions:
Inside of the command file I have sqlplus commands pl/sql block and sql select statement.
I need to do some checking on the input parameter, so I wrote plsql with if - else and assign a value to sqlplus global var. depend on the condition. Then I wonted to reference the global var. in the SQL where clause that is outside of the PL/SQL block, I am getting and error MSG.
Is there any body can help me with that I really appreciated this is how the command file looks like:
spool outfile
set verify off
…
…
variable g_aff varchar(20)
declare
firstarg varchar2(20) := '&3';
begin
if firstarg = 'all' then :g_aff := '1=1'; else :g_aff := ' a.aff_name = "&3" '; end if;
print g_aff
select distinct .....
..... from .... where..... and ...... and g_aff ====> here where I want that the value that g_aff get from plsql block will be assign.and .....
Here how the plsql look like:
declare
....
begin
if x =1 then select age,name,address from emp where name = 'dan'; else select ..... from…..... where…..; end if;
Thanks in advance,
Dori
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Mon Dec 06 1999 - 11:28:47 CST
![]() |
![]() |