|
|
|
Re: SQLPlus command parser [message #591776 is a reply to message #591765] |
Wed, 31 July 2013 09:56 |
gazzag
Messages: 1119 Registered: November 2010 Location: Bedwas, UK
|
Senior Member |
|
|
I'm guessing he wants a program to syntax-check a SQL script before bundling it up into a release, for example.
sabaka, you should have a testing environment to sanity check scripts/releases. They should be thoroughly tested before they get anywhere near a production environment.
[edit: typo]
[Updated on: Wed, 31 July 2013 10:54] Report message to a moderator
|
|
|
|
Re: SQLPlus command parser [message #591795 is a reply to message #591776] |
Wed, 31 July 2013 10:55 |
|
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Quote:I'm guessing he wants a program to syntax-check a SQL script before bundling it up into a release, for example.
If this is the case then DBMS_SQL can do it easily.
Here's a SQL parser:
create or replace procedure checkSQL (p_sql varchar2)
authid current_user
is
handle int := dbms_sql.open_cursor;
begin
dbms_sql.parse (handle, p_sql, dbms_sql.native);
dbms_sql.close_cursor (handle);
exception
when others then
if dbms_sql.is_open(handle) then dbms_sql.close_cursor (handle); end if;
raise;
end;
/
SQL> exec checkSQL('select * from dual');
PL/SQL procedure successfully completed.
SQL> exec checkSQL('select michel from dual');
BEGIN checkSQL('select michel from dual'); END;
*
ERROR at line 1:
ORA-00904: "MICHEL": invalid identifier
ORA-06512: at "MICHEL.CHECKSQL", line 11
ORA-06512: at line 1
SQL> exec checkSQL(q'[update dba_users set username='FOO']')
BEGIN checkSQL(q'[update dba_users set username='FOO']'); END;
*
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "MICHEL.CHECKSQL", line 11
ORA-06512: at line 1
Regards
Michel
|
|
|