A less "Oracle" only solution is to query the table/view in question
using predicate of 1 = 2

prepare and execute a statement like this:
        select * from view/table where 1 = 2
Now, if the view is doing A LOT of work behind the scenes, performance
could be questionable.  <YMMV>

In a future release of DBI, the method column_info will provide a
means to check validity.  I haven't heard when this release is
scheduled.


Tom


> -----Original Message-----
> From: Stan Brown [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 09, 2002 1:53 PM
> To: [EMAIL PROTECTED]
> Subject: How to safely check an SQL statement?
> 
> 
> I'm modifying a script that connects to Oracle to collect data. Previously
> it could only get data from a table, and now I'm adding the ability to get
> data from a view.
> 
> Because of the environment it runs in, and the fact that it's configuration
> table driven, on the fly. I need a LOT of error checking.
> 
> So that's where it gets interesting. Previously I was able to check for
> existence of the requested table, and column, by checking the appropriate
> 
> Now that I'allowing views, the SQL statement can be retrived from the
> "TEXT" collumn of the "ALL_VIEWS" view. However, that does not garunteee
> that the sattement still points to valid table/collumn pairs.
> 
> What I have in mind is doing a prepare on this statement, and checking the
> return code. Does this sound like it will catch invalis statements? If so,
> how do I do this safetly without risk of causing the script to bail out on
> an error?
> Oravle system tables.
> 
> table tha
> 

-- 
Thomas A. Lowery
See DBI/FAQ http://tlowery.hypermart.net

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com

Reply via email to