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

Home -> Community -> Usenet -> c.d.o.misc -> Re: PL/SQL error

Re: PL/SQL error

From: Gennaro Napolitano <Gennaro.Napolitano_at_italdata.it>
Date: Fri, 02 Jul 1999 15:29:05 +0200
Message-ID: <377CBEA1.34A4DB70@italdata.it>

Morten wrote:

> Hi, I just made my first PL/SQL code. When I try to run it I
> get the following error
>
> ERROR at line 13:
> ORA-06550: line 13, column 9:
> PLS-00201: identifier 'V_DOCTABLE' must be declared
> ORA-06550: line 11, column 4:
> PL/SQL: SQL Statement ignored
>
> As you can see in the code below, v_docTable is declared
> (as far as I can tell), who doesn't the compiler agree?
>
> Thanks
>
> Morten
>
> DECLARE
> v_docTable VARCHAR(32);
>
> CURSOR c_docTypeCursor IS
> SELECT table_name
> FROM doc_type;
>
> BEGIN
> FOR v_docTable IN c_docTypeCursor
> LOOP
> INSERT INTO document (id, type)
> SELECT v_docTable.id, doc_type.id
> FROM v_docTable, doc_type
> WHERE doc_type.table_name = v_docTable;
> END LOOP;
> CLOSE c_docTypeCursor;
> COMMIT;
> END;
From Oracle Documentation:

Cursor FOR Loops

In most situations that require an explicit cursor, you can simplify coding by using a cursor FOR loop instead of the OPEN, FETCH, and CLOSE statements. A cursor FOR loop implicitly declares its loop index as a record that represents a row in a database table, opens a cursor, repeatedly fetches rows of values from the result set into fields in the record, then closes the cursor when all rows have been processed. In the following example, the cursor FOR loop implicitly declares emp_rec as a record:

DECLARE
   CURSOR c1 IS

      SELECT ename, sal, hiredate, deptno FROM emp;    ...
BEGIN
   FOR emp_rec IN c1 LOOP

      ...
      salary_total :=  salary_total + emp_rec.sal;
   END LOOP; To reference individual fields in the record, you use dot notation, in which a dot (.) serves as the component (field) selector.

Hope this help.

Ciao Gennaro Received on Fri Jul 02 1999 - 08:29:05 CDT

Original text of this message

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