Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Query result in a Variable ?
hello,
There are various ways of getting information from SQL*Plus out to
the operating system. None that i know of are very nice, basically
because Oracle runs on so many platform that they have used the lowest
common denominator, mainly files.
Therefore:
Variables in SQL*Plus.
There are two kinds.
Example:
define RowCountDV=''
column SetRowCountDV new_value RowCountDV;
select to_char( Count(*) ) SetRowCountDV from Table /
ways to see the value is:
prompt &RowCountDV.
or
select '&RowCountDV.' from dual;
variable BVRowCount number;
They are set from PL/SQL and are identified as bind variables by using a ':' (colon) at the start of the name.
They can be set using assignment statements ( e.g. :BVRowCount := 3)
or using
' select ... into :bind_variable' statements.
Example:
begin
select count(*) into :BVRowCount from Table;
end;
/
the value can be used by SQL*Plus in select statements (and where clauses etc). e.g.
select :BVRowCount from dual;
or printed using the 'PRINT' command.
if this is all very obvious or not what you wanted to know then oops.
graham (aka grumpy)
tero.rantaniemi_at_tele.telebox.fi (Tero Rantaniemi) wrote...
| Hi !
|
| I have a problem. I don't know how to use variables in sql.
| Example:
|
| SELECT count(*) FROM table;
|
| I want to put the result in a variable and take it to UNIX.
| Do I have to define a variable first and then and how ....??
|
| THANK YOU !
|
| email: tero.rantaniemi_at_tele.fi
Graham Miller ...
Opinions expressed are mine, they are free, and worth exactly what they cost.
Received on Sun Jun 15 1997 - 00:00:00 CDT
![]() |
![]() |