Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing PL/SQL code to check against syntax and semantic errors

Please consider following scenario:

  • I have a Text-Area and a Button on UI.
  • User will enter a PL/SQL block in Text-Area.
  • When user will press Button, I want to check for syntax and semantic errors in that block without executing it.

I would really like a solution where I don't have to install anything more.

Environment information:

  1. Java 1.6.31
  2. Oracle database 11g
like image 655
VishalDevgire Avatar asked Apr 10 '26 23:04

VishalDevgire


1 Answers

SQL> explain plan for select from dual;
explain plan for select from dual
                        *
ERROR at line 1:
ORA-00936: missing expression


SQL> explain plan for select * from dual;

Explained.

or

declare
  c integer := dbms_sql.open_cursor();
begin
 dbms_sql.parse(c, 'select * emp', dbms_sql.native);
 dbms_sql.close_cursor(c);
end;
/
Error at line 1
ORA-00923: FROM keyword not found where expected
ORA-06512: at "SYS.DBMS_SQL", line 1053
ORA-06512: at line 4

or hit http://www.softpedia.com/get/Internet/Servers/Database-Utils/EasySQL-Checker-for-Oracle.shtml

like image 103
tomasb Avatar answered Apr 13 '26 11:04

tomasb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!