 |
|
ORA-00900: invalid SQL statement tips
Oracle Error Tips by Burleson Consulting
|
Oracle says this about the ORA-00900:
ORA-00900
invalid SQL statement
- Cause:
The statement is not recognized as a valid SQL
statement. This error can occur if the Procedural Option
is not installed and a SQL statement is issued that
requires this option (for example, a CREATE PROCEDURE
statement). You can determine if the Procedural Option
is installed by starting SQL*Plus. If the PL/SQL banner
is not displayed, then the option is not installed.
- Action:
Correct the syntax or install the Procedural Option.
Oracle
offers information regarding ORA-00900, when it occurs while
attempting to use a database link. Many users find that they are
encountering ORA-00900 as they attempt to query fields which may have worked
before 2000.
To resolve ORA-00900, on the local database, try altering your init.ora
parameter NLS_DATE_FORMAT, then use double quotes (instead of single)
around the value. For example:
NLS_DATE_FORMAT
= "DD-MON-YYYY"
The next step in
resolving ORA-00900 is to restart the database.
If you want to
instead alter the parameter in the session, you can try:
SQL> alter
session set NLS_DATE_FORMAT = "DD-MON-YYYY";
The reason
ORA-00900 is thrown is that the single quotes become incorrectly read and so the
results lose validity.
A user on
this forum also encountered ORA-00900:
Question:
I am trying to execute a procedure using
parameter, if there are two parameters, I do not receive ORA-00900, but for
other parameter, this message is thrown:
ORA-00900: invalid SQL statement
When I try this, my procedure attempts to
update. This update is successful with the backend and three rows,
however, it does not update the entire table. Her is the procedure:
select ,insert,update grant permission
are given to the table.
update statement within procedure:
update table_customer set x_customer_value =
(select to_number(FLD2) from cfg_asciifiles
where to_number(FLD1)='100000195'
and process_flag is null
and inputfilename='c100'
and cno='test1.txt')
where x_customer_id in (select to_number(FLD1)
from cfg_asciifiles
where process_flag is null
and inputfilename='test1.txt'
and cno='c100');
Answer:
The ORA-00900 issues have to do with the
parameters passing through the procedure because there are text strings being
used. You should use a dynamic SQL in your stored procedure:
cmmd:='ALTER SESSION SET CURSOR_SHARING=SIMILAR';
username:=SYS_CONTEXT('USERENV','SESSION_USER');
IF username LIKE 'APPL%' then
EXECUTE IMMEDIATE cmmd;
EXECUTE IMMEDIATE cmmd2;
END IF;
For more information on this try:
Oracle Dynamic PL/SQL Stored Procedures
Late Binding and Runtime Binding in PL/SQL
|