Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: SELECT INTO in SQL*Plus
On Tue, 28 Dec 1999 21:34:54 +0100, Cong TANG <lai-tang_at_mycity.at>
wrote:
>SELECT ... INTO is a PL/SQL statement, hence must be part of a PL/SQL
>block.
>Example:
>
>SQL> variable x number;
>SQL> begin
> 2 select count(*) into :x
> 3 from emp;
> 4 end;
> 5 /
>
>PL/SQL procedure successfully completed.
>
>SQL> print x;
>
> X
>---------
> 14
>
>Cong Tang
>
>NetComrade wrote:
>
>> SQL> variable i number
>> SQL> select count(*) into :i from dba_tables;
>>
>> COUNT(*)
>> ----------
>> 149
>>
>> SQL> print i
>>
>> I
>> ----------
>>
>> SQL>
>>
>> How come this doesn't work? I wanted to use this to do some
>> arithmetics later in my report.
>>
>> Thanx.
>>
>> ---------------
>> In case I forgot to mention:
>> We use Oracle 7.3.4 on Solaris 2.6, 2.7 boxes
>> ---------------
>> Andrey Dmitriev eFax: (978) 383-5892 Daytime: (917) 750-3630
>> AOL: NetComrade ICQ: 11340726 remove NSPAM to email
>
alternately this command works too:
SQL>variable i number
SQL>execute select count(*) into :i from dba_tables;
Received on Sat Jan 01 2000 - 07:51:46 CST
![]() |
![]() |