#!/bin/ksh93
sqlplus -s xxx/yyy <<EOF
WHENEVER SQLERROR EXIT SQL.SQLCODE;
variable recordId number;
declare
sql_ins varchar (2000):='';
begin
sql_ins:=q'{insert into xxx values (yyy)}';
execute immediate sql_ins;
exception
WHEN OTHERS then
:recordId:=SQLCODE;
end;
/
exit :recordId;
EOF
echo 'rc='$?
~