This is sending me a bit mad. I'm trying to add in a variable to a procedure, but it wasn't working - I just got this error message:
[Error] Syntax check (25: 7): ERROR line 25, col 7, ending_line 25, ending_col 12, Found 'number', Expecting: ; -or- .. := DEFAULT NOT NULL -or- % -or- ( . @
I knocked up a really basic procedure below to isolate the problem and now I'm completely stuck, as every basic syntax guide I've looked as says to do what I've done. Why can't i declare variables as shown below? I normally code in SQL Server if that's any clue as to my problem. Many thanks if anyone can help!
CREATE OR REPLACE PROCEDURE MRCS.pro_xxx_test1 (cats out sys_refcursor)
IS
declare
spoon number;
balls varchar2(3);
BEGIN
open cats for select * from dual;
end;
/
After the declaration, PL/SQL allocates memory for the variable's value and the storage location is identified by the variable name. Syntax for declaring variable: Following is the syntax for declaring variable: variable_name [CONSTANT] datatype [NOT NULL] [:= | DEFAULT initial_value]
Syntax Error. 1. This is a type of error that is encountered while the program is running. This is an error encountered in the syntax of a sequence of characters or the tokens intended to be written in a particular language.
You can create a record variable in any of these ways: Define a record type and then declare a variable of that type. Use %ROWTYPE to declare a record variable that represents either a full or partial row of a database table or view.
Remove the "DECLARE". Not needed in a function / procedure declaration
CREATE OR REPLACE PROCEDURE MRCS.pro_xxx_test1 (cats out sys_refcursor)
IS
spoon number;
balls varchar2(3);
BEGIN
open cats for select * from dual;
end;
/
Declare local variable between IS
and BEGIN
block for procedure and function
CREATE OR REPLACE PROCEDURE MRCS.pro_xxx_test1 (cats out sys_refcursor)
IS
spoon number;
balls varchar2(3);
BEGIN
open cats for select * from dual;
end;
/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With