This is a really simple question, but I can't seem to find the syntax for this anywhere.
I have something like this:
FUNCTION some_function
(
t_string IN VARCHAR2
) RETURN NUMBER IS
some_variable NUMBER;
BEGIN
//logic
END some_function;
It hits the some_variable declaration and tells me it was expecting "language" where/how do I declare variables? I've seen examples which have done it this way but for some reason it doesn't work.
Many thanks, Fugu
The declaration section is required if any variables are to be used in a PL/SQL block. The declaration section also defines cursors, types, local procedures, and functions that are used in a block. If no variables or other elements need to be declared, then this section may be omitted.
To learn how to declare a constant in PL/SQL let's quickly take a look at the syntax. This is our syntax: constant_name CONSTANT datatype (data-width) := value; First you need to give a valid name to your constant followed by keyword CONSTANT that indicates the declaration of a constant in your program.
Did not found anything wrong with your declared variable:
create or replace FUNCTION some_function
(
t_string IN VARCHAR2
) RETURN NUMBER
IS
some_variable NUMBER;
BEGIN
return some_variable;
END some_function;
Returned NULL as expected:
select some_function('ff') from dual
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