Getting invalid identifier in DBMS_SQL.Parse [message #281153] |
Thu, 15 November 2007 22:12 |
poonster
Messages: 2 Registered: November 2007
|
Junior Member |
|
|
Hi guys, I need help in my stored proc. I have no problems in compiling the stored proc. But when I run it, I get the error
ORA-00904: "DATEEND": invalid identifier.
Here's my code:
DBMS_SQL.PARSE(cur, 'SELECT COUNT(*) INTO countTable FROM PurchaseDetails_' || month || ' WHERE
PurchaseDATE BETWEEN dateStart AND dateEnd', DBMS_SQL.NATIVE);
I've defined dateStart and dateEnd. But it keeps telling me that
ORA-00904: "DATEEND": invalid identifier. Is there a syntax error with my code? I've tried to hardcode the statement and just executing it without using DBMS_SQL.PARSE and it works.
SELECT COUNT(*) INTO countTable FROM PurchaseDetails_10 WHERE
PurchaseDATE BETWEEN dateStart AND dateEnd;
|
|
|
Re: Getting invalid identifier in DBMS_SQL.Parse [message #281155 is a reply to message #281153] |
Thu, 15 November 2007 22:26 |
Frank
Messages: 7901 Registered: March 2000
|
Senior Member |
|
|
You have to test your generated statement in sqlplus, not from pl/sql.
dateend and datestart are probably pl/sql-variables? Those are not available in sql.
Why do you use dbms_sql? Nowadays we use execute immediate. It's far easier to use!
|
|
|
|