下面的插入代码在SQL开发人员中工作正常但在sql plus中失败。
create table abc(metric varchar2(10), line number(2), text varchar2(2000));
insert into abc
(metric, line, text)
values('abc', 1, q'#declare
k_sid constant varchar2(100) := upper(sys_context('USERENV', 'DB_NAME'));
-- Cusor-FOR-loop over all spy_configs for k_sme ...
for r_stmt in (select k_sid as instance
,k_sme as metric
,key
,value
,'ERROR - spfile-parameter: '||key||' must be set to: '||value||' but is not - please check and change it !!!' as text
from bmw_system.bmw_spy_conf
raise_application_error (-20001, ' - '||sqlcode||' - '||sqlerrm,true);
end;#')
是否有通过sql plus参数的任何解决方案。非常感谢任何指针。
的问候, 和Sandeep
答案 0 :(得分:2)
尝试:
set sqlt /
insert into abc
(metric, line, text)
values('abc', 1, q'[declare
k_sid constant varchar2(100) := upper(sys_context('USERENV', 'DB_NAME'));
-- Cusor-FOR-loop over all spy_configs for k_sme ...
for r_stmt in (select k_sid as instance
,k_sme as metric
,key
,value
,'ERROR - spfile-parameter: '||key||' must be set to: '||value||' but is not - please check and change it !!!' as text
from bmw_system.bmw_spy_conf
raise_application_error (-20001, ' - '||sqlcode||' - '||sqlerrm,true);
end;]')
/
set sqlt ;
http://docs.oracle.com/cd/B28359_01/server.111/b31189/ch12040.htm#i2498515
SET SQLT [ERMINATOR] {; | c | ON | OFF} 强>
设置用于结束PL / SQL块或SQL语句的脚本或数据条目的字符,以执行脚本并将其加载到缓冲区中。
它不能是字母数字字符或空格。 OFF表示SQL * Plus不识别命令终止符;通过输入空行或斜杠(/)来终止SQL命令。如果SQLBLANKLINES设置为ON,则必须使用BLOCKTERMINATOR来终止SQL命令。 ON将终结符重置为默认分号(;)。
答案 1 :(得分:0)
将命令保存到sql文件中,然后从SQL Plus执行该文件:http://www.techonthenet.com/oracle/questions/script.php
SQL > @{path}{file}