I have a problem with some P-SQL syntax. I reduced the sample code to its minimum below.
The following works:
CREATE OR REPLACE FUNCTION MyFunction(LINE_ID SMALLINT)
RETURN VARCHAR2 IS
tmp VARCHAR2(4000);
BEGIN
tmp := CAST(LINE_ID AS VARCHAR2);
RETURN(tmp);
END MyFunction;
/
However, I need to change the LINE_ID parameter to NUMBER (5, 0), after which the following does not work:
CREATE OR REPLACE FUNCTION MyFunction2(LINE_ID NUMBER(5, 0))
RETURN VARCHAR2 IS
tmp VARCHAR2(4000);
BEGIN
tmp := CAST(LINE_ID AS VARCHAR2);
RETURN(tmp);
END MyFunction2;
/
Error message in Oracle SQL Developer 3.2.10.09
Error (1.36): PLS-00103: The symbol "(" was detected while waiting for one of the following :: =.), The symbol @% is default. The symbol ": =" has been replaced by "(" continue.
How to write an instruction CASTto work with NUMBER(5, 0)instead SMALLINT?
Again, this is not the original code, but I'm looking for a solution that does not deviate too much from the second version, and preferably another function call. The return type is VARCHAR2also important.