Mel,
First, the script you are trying to execute contain statements that are not known by the Oracle database. More specifically these:
SET ECHO ON;
set serveroutput on;
set feedback on;
set define off;
set numformat 999999999999;
set colsep ',';
These are SQL*Plus (or other Oracle client tools) specific and are not supported by DbVisualizer.
To execute the SQL part of the script you will need to instruct DbVisualizer to not split the script into separate statements. Semicolon (";") is used by default to split the script.
These are the options you have to run the script without splitting at semicolon:
1) Use Execute Buffer instead:
http://www.dbvis.com/doc/main/doc/ug/sqlCommander/sqlCommander.html#mozTocId958847
2) Place the script within SQL Block delimiters (--/ and /) by default):
http://www.dbvis.com/doc/main/doc/ug/sqlCommander/sqlCommander.html#mozTocId652495
3) Use the @delimiter command to temporarily change the statement delimiter:
http://www.dbvis.com/doc/main/doc/ug/sqlCommander/sqlCommander.html#mozTocId437790
Please see the referenced sections of the Users Guide for details.
Here is a revised version of your script using option 2) above:
alter session set current_schema = LIFESMART;
--/
DECLARE
v_rfs_id VARCHAR(16) := 'testv';
v_expected_rows PLS_INTEGER := 0;
lst_dml_exception EXCEPTION;
PROCEDURE printELAHeader
IS
dbName v$database.name%TYPE;
BEGIN
dbms_output.enable(buffer_size => NULL);
select name into dbName from v$database;
dbms_output.put_line('-- START ' || v_rfs_id || ' fix on ' || dbName || ' at ' || SYSTIMESTAMP || ' by user ' || USER);
dbms_output.put_line('-- Modifying data');
END printELAHeader;
PROCEDURE printELAFooter
IS
dbName v$database.name%TYPE;
BEGIN
select name into dbName from v$database;
dbms_output.put_line('-- Done Modifying data');
dbms_output.put_line('-- END ' || v_rfs_id || ' fix on ' || dbName || ' at ' || SYSTIMESTAMP || ' by user ' || USER);
END printELAFooter;
PROCEDURE checkExpectedRows(p_expected_rows NUMBER)
IS
v_rows PLS_INTEGER := 0;
BEGIN
v_rows := SQL%ROWCOUNT;
if ( v_rows != p_expected_rows ) then
dbms_output.put_line('-- ' || v_rows || ' ROWS MODIFIED. Expected ' || p_expected_rows || '. ROLLBACK');
RAISE lst_dml_exception;
else
dbms_output.put_line('-- ' || v_rows || ' ROWS MODIFIED as expected. Mark for COMMIT');
end if;
END checkExpectedRows;
BEGIN
printELAHeader;
dbms_output.put_line('-- No exceptions. COMMIT data.');
--commit;
printELAFooter;
EXCEPTION
WHEN lst_dml_exception THEN
dbms_output.put_line('-- ROLLBACK on Bad Data Modification');
rollback;
WHEN OTHERS THEN
dbms_output.put_line('-- ROLLBACK on Exception: ' || SQLCODE || '-' || SQLERRM);
rollback;
END;
/
To run it first start DBMS output handler in the SQL Commander and then simply run it with the SQL->Execute main menu choice or the green execute button in the SQL Commander toolbar. The output is listed in the DBMS Output tab.
I hope this helps.
Regards
Roger
a
anonymous
said
almost 12 years ago
[This reply is migrated from our old forums. The original author name has been removed]
Re: Errors trying to run pl/sql script
Thanks for the reply Roger, that helped a lot.
Mel
anonymous