如何使用 PL SQL 更改 SqlPlus 结果的输出?
How can I change the output of SqlPlusresults with PLSQL?
我有一个包含 plsql 代码的脚本。代码的输出是如此复杂。
代码在这里:
#!/usr/bin/ksh
$ORACLE_HOME/bin/sqlplus<<EOF
x/xx@xxx
set serveroutput on
set sqlnumber off
set sqlblanklines off
set feedback off
DECLARE
is_found_rec boolean := false;
CURSOR c1
IS
select name from rdsolucadm.BPM_T_SEMAPHORE where value in ('0') and description like 'R%';
BEGIN
FOR r1 IN c1
LOOP
is_found_rec := true;
update RDSOLUCADM.BPM_T_SEMAPHORE set value ='2' where value in ('0') and description like 'R%';
commit;
dbms_output.put_line ('BPM_T_SEMAPHORE table is updated.');
END LOOP;
if not is_found_rec then
dbms_output.put_line ('BPM_T_SEMAPHORE table is NOT updated!!!');
end if;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(SubStr('Error '||TO_CHAR(SQLCODE)||': '||SQLERRM, 1, 255));
RAISE;
END;
/
exit
EOF
And the result is as below:
Connected to: Oracle Database 11g Enterprise Edition Release
11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real
Application Testing options
SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL>
SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL>
BPM_T_SEMAPHORE table is NOT updated!!!
SQL> Disconnected from Oracle
Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage
Management, OLAP, Data Mining and Real Application Testing options
我不想看到很多"SQL> SQL> SQL> SQL> SQL> ....."
如何设置这个属性?你能帮帮我吗?
谢谢,
最好的问候
您只是在调用 sqlplus
时缺少 -s
标志。
示例代码:
oracle@***:/home/oracle/testing> cat test.sh
$ORACLE_HOME/bin/sqlplus -s<<EOF
XXX/XXX
set serveroutput on
set sqlnumber off
set sqlblanklines off
set feedback off
BEGIN
dbms_output.put_line('testing');
END;
/
exit
EOF
没有 -s
标志的示例输出:
oracle@***:/home/oracle/testing> sh test.sh
SQL*Plus: Release 11.2.0.3.0 Production on Fri Mar 13 08:12:21 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Enter user-name:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> testing
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
带有 -s
标志的示例:
oracle@XXX:/home/oracle/testing> sh test.sh
testing
我有一个包含 plsql 代码的脚本。代码的输出是如此复杂。 代码在这里:
#!/usr/bin/ksh
$ORACLE_HOME/bin/sqlplus<<EOF
x/xx@xxx
set serveroutput on
set sqlnumber off
set sqlblanklines off
set feedback off
DECLARE
is_found_rec boolean := false;
CURSOR c1
IS
select name from rdsolucadm.BPM_T_SEMAPHORE where value in ('0') and description like 'R%';
BEGIN
FOR r1 IN c1
LOOP
is_found_rec := true;
update RDSOLUCADM.BPM_T_SEMAPHORE set value ='2' where value in ('0') and description like 'R%';
commit;
dbms_output.put_line ('BPM_T_SEMAPHORE table is updated.');
END LOOP;
if not is_found_rec then
dbms_output.put_line ('BPM_T_SEMAPHORE table is NOT updated!!!');
end if;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(SubStr('Error '||TO_CHAR(SQLCODE)||': '||SQLERRM, 1, 255));
RAISE;
END;
/
exit
EOF
And the result is as below:
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options
SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> BPM_T_SEMAPHORE table is NOT updated!!!
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options
我不想看到很多"SQL> SQL> SQL> SQL> SQL> ....." 如何设置这个属性?你能帮帮我吗?
谢谢, 最好的问候
您只是在调用 sqlplus
时缺少 -s
标志。
示例代码:
oracle@***:/home/oracle/testing> cat test.sh
$ORACLE_HOME/bin/sqlplus -s<<EOF
XXX/XXX
set serveroutput on
set sqlnumber off
set sqlblanklines off
set feedback off
BEGIN
dbms_output.put_line('testing');
END;
/
exit
EOF
没有 -s
标志的示例输出:
oracle@***:/home/oracle/testing> sh test.sh
SQL*Plus: Release 11.2.0.3.0 Production on Fri Mar 13 08:12:21 2015
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Enter user-name:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> testing
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
带有 -s
标志的示例:
oracle@XXX:/home/oracle/testing> sh test.sh
testing