Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Q: Using of variables in PL/SQL in a LOOP??
Ralf Bender wrote:
> Hello togehter!
>
> Call me blind, but why is this not working. Is it not possible to use
> sFlag(i) or sVNr(i) in a LOOP? :
>
> CREATE OR REPLACE TRIGGER trig_ai2_ABTEST
> AFTER INSERT ON ABTEST
> FOR EACH ROW
> DECLARE
> sFlag1 BOOLEAN;
> sVNr1 CHAR(5);
> sFlag2 BOOLEAN;
> sVNr2 CHAR(5);
>
> stemp CHAR(1);
> sSQLStatement VARCHAR(250);
> BEGIN
> IF INSERTING THEN
> IF :NEW.V_NUMMER1 IS NOT NULL AND :NEW.SEITE = '001' THEN
> sVNr1 := :NEW.V_NUMMER1;
> sFlag1 := TRUE;
> dbms_output.put_line(SYSDATE ||'Flag1:');
> END IF;
> IF :NEW.V_NUMMER2 IS NOT NULL AND :NEW.SEITE = '001' THEN
> sVNr2 := :NEW.V_NUMMER2;
> sFlag2 := TRUE;
> dbms_output.put_line(SYSDATE || 'Flag2:');
> END IF;
>
> FOR i IN 1 .. 4 LOOP
> IF sFlag(i) = TRUE THEN
> dbms_output.put_line(SYSDATE || 'Flag(I):'||sVNr(i));
> END IF;
> END LOOP;
> END IF;
> END;
>
> /
Sflag is not a collection. sVNR is also not a collection, but a string. The (<subscript>) syntax applies to collections only. So yes, you need more coffee.
-- Sybrand Bakker Senior Oracle DBAReceived on Tue Sep 12 2006 - 05:23:51 CDT
![]() |
![]() |