[英]Updating a column in a table with a pl/sql anonymous block
Below insert code works fine at SQL developer but failed in sql plus. 下面的插入代码在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;#')
Is there any solution through sql plus parameter.Any pointer will be greatly appreciated. 有没有通过sql plus parameter的解决方案。任何指针将不胜感激。
REgards, Sandeep 桑迪普·雷加德斯
Try: 尝试:
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 http://docs.oracle.com/cd/B28359_01/server.111/b31189/ch12040.htm#i2498515
SET SQLT[ERMINATOR] {;
SET SQLT [ERMINATOR] {; |
| c |
c | ON |
开| OFF}
OFF}
Sets the character used to end script or data entry for PL/SQL blocks or SQL statements, to execute the script, and to load it into the buffer.
设置用于结束PL / SQL块或SQL语句的脚本或数据输入,执行脚本并将其加载到缓冲区的字符。
It cannot be an alphanumeric character or a whitespace.
它不能是字母数字字符或空格。 OFF means that SQL*Plus recognizes no command terminator;
OFF表示SQL * Plus不识别命令终止符; you terminate a SQL command by entering an empty line or a slash (/).
您通过输入空行或斜杠(/)终止SQL命令。 If SQLBLANKLINES is set ON, you must use the BLOCKTERMINATOR to terminate a SQL command.
如果将SQLBLANKLINES设置为ON,则必须使用BLOCKTERMINATOR终止SQL命令。 ON resets the terminator to the default semicolon (;).
ON将终止符重置为默认的分号(;)。
将命令保存到sql文件中,然后从SQL Plus执行该文件: http : //www.techonthenet.com/oracle/questions/script.php
SQL > @{path}{file}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.