Re: Can I do this A||1:= 100; in PLSQL.
Date: 28 Aug 2001 18:11:51 -0700
Message-ID: <9mhfgn022jk_at_drn.newsguy.com>
In article <eb00ec08.0108281312.77ed0dc9_at_posting.google.com>, safeer_at_nettaxi.com
says...
>
>I am just trying to do the following code, how can I do that in plsql,
>I don't want to use array or PLSQL tables.
>
>declare
>a1 number;
>a2 number;
>a3 number;
>a4 number;
>begin
> for i in 1 .. 4
> loop
> a||i := i;
> end loop;
>end;
>
>Regards,
>
>Muhamamd Safeer.
you cannot do that but you can do this:
declare
type numArray is table of number index by binary integer;
a numArray;
begin
for i in 1 .. 4
loop
a(i) := i;
end loop;
end;
You could also (but it wouldn't be a good thing) do this:
create or replace package my_pkg
as
a1 number; a2 number; a3 number; a4 number;
end;
/
begin
for i in 1 .. 4
loop
execute immediate 'begin a' ||i || ' := :i; end;' using IN i;
end loop;
end;
and set the global package variables.
-- Thomas Kyte (tkyte_at_us.oracle.com) http://asktom.oracle.com/ Expert one on one Oracle, programming techniques and solutions for Oracle. http://www.amazon.com/exec/obidos/ASIN/1861004826/ Opinions are mine and do not necessarily reflect those of Oracle CorpReceived on Wed Aug 29 2001 - 03:11:51 CEST