2012-04-10 18 views
3

以下のスクリプトを.sqlファイル内のスクリプトで実行しています。私はWindowsのコマンドラインコンソールを使用してsqlplusを起動しています。スクリプトが終了すると、INSERT文で追加されたレコードの数を見ることができなかったことを除いて、すべてがうまく見えます。あなたはまた、次の出力を見ることができます:SQLPLUS影響を受けた行数を表示しません

SCRIPT

WHENEVER SQLERROR EXIT 1 ROLLBACK 
WHENEVER OSERROR EXIT 1 ROLLBACK 
SET FEEDBACK ON 
SET VERIFY ON 
BEGIN 
DBMS_OUTPUT.put_line('Output Nothing'); 
END; 
/
INSERT INTO ......... 

COMMIT; 
QUIT; 
/

OUTPUTは、私はヒキガエル/ SQLNavigatorのようなツールで同じSQLを実行すると、私は見ることができ

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Apr 9 22:08:47 2012 

Copyright (c) 1982, 2005, Oracle. All rights reserved. 

Connected to: 
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production 
With the Partitioning, Automatic Storage Management, OLAP, Data Mining 
and Real Application Testing options 

PL/SQL procedure successfully completed. 

Commit complete. 

Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64 
bit Production 
With the Partitioning, Automatic Storage Management, OLAP, Data Mining 
and Real Application Testing options 

を表示しました追加された行の数(下記の**マーク付きの行を参照)。

OUTPUTDISPLAYEDはヒキガエル

Processing ... 
SET FEEDBACK ON 

SQL*Plus command ignored. 
Processing ... 
SET VERIFY ON 


SQL*Plus command ignored. 
Processing ... 
BEGIN 
DBMS_OUTPUT.put_line('Doing Nothing'); 
END; 

Doing Nothing 
Processing ... 
INSERT INTO ....... 

**11 row(s) inserted** 

Processing ... 
COMMIT 

Processing ... 
QUIT; 

SQL*Plus command ignored. 

ONあなたはおそらく、私はシンプル'sqlplus'を通じて、このスクリプトを実行する場合でも、私はこのSQLの影響を受けた行数をgeting役立ちます設定を教えてもらえますか?

+0

の可能重複[PLSQLのプロシージャ内のINSERTは教えてくれない

挿入された行の数を実行し、この場合、文の統計情報を表示
set echo on set autotrace on 

いくつの行が挿入された](http://stackoverflow.com/questions/4139945/insert-inside-plsql-procedure-does-not-tell-how-manyrows-were-inserted) – paxdiablo

+0

INSERTはしかし、pl/sqlブロックの内側にあります。 – DCookie

答えて

2

SQL * Plusは、行数を出力リレーしませんが、あなたのような何かを明示的にそれを行うことができます。

INSERT blah blah blah; 
DBMS_OUTPUT.put_line (SQL%ROWCOUNT); 
0

は11gクライアントと私のために動作するようです:

C:\>sqlplus user/pw 

SQL*Plus: Release 11.2.0.1.0 Production on Mon Apr 9 21:12:12 2012 

Copyright (c) 1982, 2010, Oracle. All rights reserved. 

Connected to: 
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production 
With the Partitioning, OLAP, Data Mining and Real Application Testing options 

SQL> insert into testing (select 1,'XX' from dual connect by level < 11); 

10 rows created. 

SQL> 

私はdidnの10gのクライアントが別々に働いたとは思えませんが、今はテストできません。

EDIT:

は、10gのsqlplusで同じように動作します。今日あなたの正確なスクリプトを実行しました:

C:\>sqlplus user/[email protected] 

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Apr 10 09:12:26 2012 

Copyright (c) 1982, 2005, Oracle. All rights reserved. 


Connected to: 
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production 
With the Partitioning, OLAP, Data Mining and Real Application Testing options 

DB> WHENEVER SQLERROR EXIT 1 ROLLBACK 
DB> WHENEVER OSERROR EXIT 1 ROLLBACK 
DB> SET FEEDBACK ON 
DB> SET VERIFY ON 
DB> BEGIN 
    2  DBMS_OUTPUT.put_line('Output Nothing'); 
    3 END; 
    4/
Output Nothing 

PL/SQL procedure successfully completed. 

DB> insert into xx (select 'AA' from dual connect by level < 10); 

9 rows created. 

DB> COMMIT; 

Commit complete. 

DB> QUIT; 
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production 
With the Partitioning, OLAP, Data Mining and Real Application Testing options 

C:\> 

1行または9文字を挿入しても問題ありません。メッセージが表示されます。私はあなたのスクリプトの例から外れる何かがあると推測しています。 INSERTはBEGIN/ENDブロック内にありますか?それはメッセージを抑制する。

3

SET FEEDBACK ONのデフォルトのしきい値は6です。少ない数のフィードバックが必要な場合は、「SET FEEDBACK 1」を使用します。

+0

これは私のために何の違いもありませんでした。 – DCookie

0
rem to see Pl/SQL "print" statements: 
set serveroutput on 
0

使用

コマンドは
WHENEVER SQLERROR EXIT 1 ROLLBACK 
WHENEVER OSERROR EXIT 1 ROLLBACK 
SET FEEDBACK ON 
SET VERIFY ON 
set echo on 
set autotrace on 
BEGIN 
DBMS_OUTPUT.put_line('Output Nothing'); 
END; 
/
INSERT INTO ......... 

COMMIT; 

QUIT; 
/
関連する問題