Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: PLS-00302 error

Re: PLS-00302 error

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: 2000/05/04
Message-ID: <957468750.7582.0.pluto.d4ee154e@news.demon.nl>#1/1

Gennady <gennadyb_at_halcosoftware.com> schreef in berichtnieuws 3911cb41$0$6553_at_fountain.mindlink.net...
> Hello,
> In my PL/SQL code I have a variable of ROWTYPE and I try to access
> the variable component using another variable, but I got an errorr:
> "PLS-00302: component 'CNROW' must be declared".
> The code is:
> declare
> cursor c1 is select * from old;
> old_row old%ROWTYPE;
> cursor c2 is select * from new;
> new_row new%ROWTYPE;
> cursor c3 is select column_name from user_tab_columns where table_name =
> 'OLD';
> cnrow user_tab_columns.column_name%TYPE;
> begin
> dbms_output.enable;
> open c1;
> open c2;
> open c3;
> loop
> fetch c1 into old_row;
> fetch c2 into new_row;
> exit when (c1%notfound or c2%notfound);
> end loop;
> loop
> fetch c3 into cnrow;
> If (old_row.cnrow = new_row.cnrow) then -- error in this line!
> dbms_output.put_line('SAME VALUE');
> else
> dbms_output.put_line('DIFFERENT VALUE');
> end if;
> exit when c3%notfound;
> end loop;
> end;
>
> How can I fix the problem??
> Thanks,
> Gennady
>
>

Pl/sql is extreemly critical to scope. It is probably confused by your cnrow definition. My policy always has been to tag records to a cursor like this new_row c2%ROWTYPE. Less prone to error (changing the tablename without changing the rowtype definition) and it always works. IMO, but that's completely up to you, I would choose more descriptive names.

Hth,

Sybrand Bakker, Oracle DBA Received on Thu May 04 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US