Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Passing bind variable from pl/sql to sql block.
Dori, you access the pl/sql value in sqlplus like this: (Notice colon
on bind variabe, definition below query result)
1* select * from cost_item where rownum = :v_charfld OPS2> /
PL ITEM_NO CODESCRIPTION
-- -------------------------------------------------- --
15 P4-0001 A REFURBISH THE M-9 MEZZANINE FOR EDS. 10-MAY-94 0 0 0 0 0 0 0 0 0 0 0 EA 1 Y 0 0
WHERE the value was filled like this:
set echo off
rem
rem Sample SQL and PL/SQL passing variable to SQL*Plus from PL/SQL
rem
variable v_charfld number
begin
select count(*)
into :v_charfld <== The return value is defined in sqlplus
from sys.dual
;
end ;
/
print v_charfld
In article <82gro6$l5e$1_at_nnrp1.deja.com>, doriskg_at_my-deja.com wrote:
> Hi there, > > I have 2 questions: > > 1. I have a sqlplus command file that accepts 3 > input parameters. > And I run it with START command. > > 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. >
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Tue Dec 07 1999 - 11:57:51 CST
![]() |
![]() |