I have a stored procedure which executes some dynamic sql, shown below. I’ve tried to cut it down as much as possible so ignore any little errors.
In the office it works, everytime, on 11.2, 10.2, 10.1. At the customers it fails with a message:
Unexpected Error
Error Message = "Msg:
MyProc
ORA-06550: line 1, column 1:
PLS-00103: Encountered the symbol "" when expecting one of the following:
begin case declare exit for function goto if loop mod null
If I capture the dynamic sql that the customer is generating and place it in a variable like below, running on work machines, it works, so it’s not that dodgy sql is getting generated. Normally the sql comes from the client so here I’ve doubled the to_date quotes.
mySQL := '
declare
pADMINDATE DATE := :1;
pEMPLOYEEIDLIKE VARCHAR2(40) := :2;
pINCLUDEEMPLOYEE number := :3;
begin
BEGIN OTHERPROC.OTHERPROC (1,TO_DATE(''2012-10-03'', ''YYYY-MM-DD''),TO_DATE(''2012-10-03'', ''YYYY-MM-DD''),0);
END;
INSERT INTO TP_EMPLOYEES (
ID,
EMPLOYEECODE
)
SELECT ROWNUM,
EMPLOYEECODE
FROM (
SELECT EMPLOYEECODE
FROM (SELECT DISTINCT EMPLOYEECODE FROM TP_EEF_TEMP) DISTINCTEMPCODES) A;
end; ';
EXECUTE IMMEDIATE
mySQL
using
pADMINDATE,
pEMPLOYEEIDLIKE,
pINCLUDEEMPLOYEE;
It’s not the database version that causes the problem, could it be permissions? It calls another stored procedure within itself which we do regularly in non dynamic sql, could it be that?
At a loss here
Thanks
It was carriage returns! Adding this line fixed the problem
A similar problem was highlighted here
https://forums.oracle.com/forums/thread.jspa?threadID=1117462
Thanks for the answers anyway, if anyone knows I would be interested in knowing what setting/patch/whatever makes Oracle sensitive to this, i.e. I tried this on 3 different versions of oracle including the one the customer was on, -but- I didn’t patch my 10.2.1 version.
Is it something that is fixed in a patch? Is it a setting?