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

后端 未结 4 814
鱼传尺愫
鱼传尺愫 2021-01-14 04:40

Please consider following scenario:

  • I have a Text-Area and a Button on UI.
  • User will enter a PL/SQL block in
4条回答
  •  伪装坚强ぢ
    2021-01-14 05:02

    If you do have access to a running Oracle system which contains the tables in question, you can use dbms_sql.parse() to check if a given piece of SQL is valid or not.

    Regular DML statements are not execute through parse(), but DDL will be executed immediately. So you might want to check if the SQL is not a DDL statement (or better, only allow certain statements to begin with).

    Note that if the database you are connecting to, does not contain the tables used in the SQL, parse() will throw an error even if the statement is syntactically correct.

提交回复
热议问题