checking SQL statement/subexpression validity

From: David Garamond <lists(at)zara(dot)6(dot)isreserved(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: checking SQL statement/subexpression validity
Date: 2005-02-09 02:55:47
Message-ID: 42097BB3.2080907@zara.6.isreserved.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I need to check whether a SQL subexpression (to be used in WHERE
clause), e.g.:

colname > 200

or an entire SELECT statement, e.g.:

SELECT * FROM t1, t2 WHERE colname > 200

is syntactically valid. Is there a quick (and also safe) way to do this?
I'm thinking of doing "SELECT ... FROM ... WHERE <SQLexpr> LIMIT 0" for
#1, but I'm not sure if it's 100% safe; and I don't know what to do with
#2. AFAIK, in, say, Perl's DBI, $dbh->prepare() doesn't check SQL syntax
and $sth->execute() actually executes the statement.

--
dave

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rick Schumeyer 2005-02-09 03:07:58 how to delete from a view
Previous Message Art Fore 2005-02-09 02:13:24 Database permissions