The forum will experience an outage sometime between February 10 at 7:00pm EST and February 12 at 11:59 EST for installation of security updates. The actual time and duration of the outage are unknown but attempts will be made to minimize the downtime. We apologize for any inconvenience.

I was thinking that I could use:

SELECT PLAN('statement goes here');

If the result is some text, then I know the syntax of the sql statement is valid.

Is there a better way of doing such validations?

I'm interested solely in validating the syntax correctness of an sql script.

asked 23 Feb '15, 05:24

tzup's gravatar image

accept rate: 0%



(23 Feb '15, 06:22) Breck Carter
Replies hidden

"DBISQL -x" might also help...

(23 Feb '15, 06:45) Volker Barth

It might be added that "select plan()" will only work for SQL statements that generate a plan, i.e. for single queries and DML statements, not for procedure calls or DDL statements. However, it seems to check whether the schema is valid for the statement, so it will notify about misspelled identifiers or non-existing tables/columns. That makes it only partially useful for "syntax-only" validation.

REWRITE() and DBISQL -x in contrast can parse all statements, however, they will only check for syntax errors (as you have asked for). E.g. the following will raise a syntax error:

GRANT SELECTX ON products for MyUser;

whereas they will not check whether "products" or "MyUser" actually do exist.

(24 Feb '15, 03:49) Volker Barth
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 23 Feb '15, 05:24

question was seen: 1,652 times

last updated: 24 Feb '15, 03:53