Need a way to redirect PL/SQL program error message to a log file when executing it in sqlplus.
Say the PL/SQL program is named send_2012.sql and it has the following exception block
EXCEPTION
WHEN NO_DATA_FOUND
THEN
var_err := 'Data not found. ';
WHEN OTHERS
THEN
var_err := 'Error in '
|| $$plsql_unit
|| ' | '
|| SQLERRM
|| ' | '
|| 'Details: '
|| DBMS_UTILITY.format_error_backtrace;
END;
To run the PL/SQL program in a KornShell (ksh) script, I have:
sqlplus some_username/'some_password' @some_database \
@/some/directory/send_2012.sql \
$parameter1 $paramenter2
Suppose error occurs when executing send_2012.sql, how can I redirect the error message from var_err to /some/log/directory/log_send_2012.txt?
Much appreciated.