Page 1 of 1

Limit to read only (no Insert, update, delete, create, etc)

Posted: Mon 06 Apr 2009 08:24
by DuckyDuck
How can I make a TOraQuery be query only ?

I allow my user to type in some SQL, then copy it to the OraQuery.SQL and run it and show the results in a wwDBGrid

I want my user to only be able to run SELECT statements. How can I prevent them from running anything else (INSERT, UPDATE, DELETE, COMMIT, GRANTS, REVOKE, CREATE, DROP, PLSQL blocks etc)

Should I be using a different ODAC component instead of a TOraQuery ?

I have tried the following, but these settings seem to only limit data changes in the grid, and do not prevent the above

// prevent updates to database data
OraQuery1.ReadOnly := TRUE;
wwDataDBGrid.ReadOnly := TRUE;
OraSession1.AutoCommit := FALSE;
OraQuery1.AutoCommit := FALSE;

thanks

Posted: Mon 06 Apr 2009 08:35
by Plash
You should call the Prepare method of TOraQuery and check the SQLType property. It should be SQL_SELECT for a SELECT statement. This constant is declared in the OraCall unit.

Note: if SQL contains PL/SQL code, the Prepare method will execute it. So you should add a different check for PL/SQL.

Posted: Mon 06 Apr 2009 09:48
by DuckyDuck
that worked, thanks