0
votes
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:

2
Remove in from the declare block. Parameters are declared as name datatype such as p_name varchar2(100);Nikhil Shetkar
You don't declare local variables as IN or OUT - that's only used when declaring procedure/function parameters.kfinity
Your declaration of p_code has a comma rather than a semi-colon at the end of the line. You don't need the word IN to declare the variables using %TYPE.BriteSponge
The code you show us is from another topic: stackoverflow.com/questions/48674120/…Tenzin

2 Answers

1
votes

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 ;.

0
votes

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;