Friday, 27 February 2015

Execute Immediate in Oracle Reports

Execute Immediate in Oracle Reports

Using this EXECUTE IMMEDIATE command directy in reports is not possible, if you tried to use, i.e. EXECUTE IMMEDIATE ‘drop TABLE TEST’,
this error message will occured,  “this feature is not supported in client-side programs”.
EXECUTE IMMEDIATE is only supported on the server side.,but you can
work around this by creating astored procedure in the database and then using this
procedure in reports.

The database stored procedure can be created as follows:

CREATE OR REPLACE PROCEDURE DYNAMIC_SQL(STMNT CHAR) IS
BEGIN
   BEGIN
     EXECUTE IMMEDIATE STMNT;
   EXCEPTION
     WHEN OTHERS THEN
       DBMS_OUTPUT.PUT_LINE('Error while executing dynamic sql');
   END;
END;

Now, this procedure can be called in Reports.
For Example:
In the BeforeParam Trigger,the procedure can be called as:
DYNAMIC_SQL('DROP TABLE TEST');
This will drop the table 'TEST' from the database.

No comments:

Post a Comment