icerabbit
icerabbit

Reputation: 89

PL/SQL Code returning an error

DECLARE
   p_code in XML_HOURS_LOAD.code%TYPE,
   p_product in XML_HOURS_LOAD.product%TYPE;
   CURSOR cXmlHoursLoadCursor IS (SELECT code, product FROM xml_hours_load); 
BEGIN
    FOR v IN cXmlHoursLoadCursor LOOP
       Cascade_Load(v.code, v.product);
       COMMIT; 
    END LOOP;
END;

I am currently encountering the following errors when trying to run the above code, what am I doing wrong? (thanks in advance):

ORA-06550: line 2, column 29: PLS-00103: Encountered the symbol "IN" when expecting one of the following:

constant exception table long double ref char time timestamp interval date binary national character nchar ORA-06550: line 2, column 74: PLS-00103: Encountered the symbol "," when expecting one of the following:

. ( * @ % & - + / at loop mod remainder rem .. || multiset ORA-06550: line 5, column 4: PLS-00103: Encountered the symbol "IS" when expecting one of the following:

:= . ) , @ % default character ORA-06550: line 13, column 4: PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:

end not pragma final instantiable order overriding static member constructor map 06550. 00000 - "line %s, column %s:\n%s" *Cause: Usually a PL/SQL compilation error. *Action:

Upvotes: 0

Views: 991

Answers (2)

Ori Marko
Ori Marko

Reputation: 58892

You are adding PL/SQL variable anchors

PL/SQL provides you with a very useful feature called variable anchors. It refers to the use of the %TYPE keyword to declare a variable with the data type is associated with a column’s data type of a particular column in a table.

This is declare as [variableName] [dataType]; for example:

v_first_name EMPLOYEES.FIRST_NAME%TYPE;

v_last_name EMPLOYEES.LAST_NAME%TYPE;

In your case

p_code XML_HOURS_LOAD.code%TYPE;
p_product XML_HOURS_LOAD.product%TYPE;

Upvotes: 0

Tenzin
Tenzin

Reputation: 2505

I see 2 things:
1) You should remove the in behind p_code and P_product. Those are not needed. A whitespace is sufficient, because they are local variables and not input/output parameters to a function/procedure
2) Behind XML_HOURS_LOAD.code%TYPE you have a , and there you need a ;.

Upvotes: 1

Related Questions