【发布时间】:2013-07-22 16:28:49
【问题描述】:
是否可以将此 PL-SQL 代码转换为 unix 代码?
declare
tipE varchar(8) := 'TEST';
begin
insert into TABLENAME VALUES (values);
if tipExec = 'TEST' then
dbms_output.put_line('INSERT is ok; called ROLLBACK in '' TEST');
ROLLBACK;
end if;
exception
when DUP_VAL_ON_INDEX then
if tipE = 'TEST' then
raise_application_error(-9999, 'DUPKEY in'' TEST');
else
raise;
end if;
when others then
raise;
end;
有可能吗?我的意思是我有一个参数“测试”或“产品”。我必须进行插入,如果此插入有 DUPKEY,我必须将其写入日志。否则我会在日志中写“INSERT is ok”。上面的代码几乎是相同的概念,但在 oracle 中。我在 unix shell 中需要这个。谢谢。
【问题讨论】:
-
'make an insert' where - 你的意思是调用 SQL*Plus 从 shell 脚本进行插入,并从那里将成功/失败消息记录到文件中? (为什么
when others then raise?这似乎毫无意义)。 -
"do the insert from a shell script, and log the success/failure message to a file from there?"是的! -
如果可能的话,从这段代码开始。这就是我想要的,但在 ksh 中
-
哪个 Unix shell?伯恩?重击?正则表达式?科恩? C壳?灰?你需要更具体一点。
-
是的,你是对的......但是 ksh
标签: oracle shell unix plsql ksh