SQL Developer query [message #549475] |
Fri, 30 March 2012 16:18 |
|
budz
Messages: 3 Registered: March 2012
|
Junior Member |
|
|
Two questions.
1.
I'm using sql developer 3.0.04
I execute set serveroutput on to see output from dbms_output statements.
In a previous version I executed this serveroutput statement ONCE and I could execute many individual anon blocks and all output was visible.
Now I have to execute set serveroutput on for EACH anon block.
Is there a setting or an option that I don't know about?
2.
Is there a way to execute various blocks of code in a sequence. The code I want to execute is below. The code always falls over at the beginning of the 2nd anon block. Any idea?
Any help is much appreciated.
Budz
drop table X cascade constraints;
CREATE TABLE X(
xid NUMBER PRIMARY KEY,
xname VARCHAR2(100) );
drop table y cascade constraints;
CREATE TABLE Y(
yid NUMBER PRIMARY KEY,
yname varchar2(100),
maxqty number );
CREATE OR REPLACE procedure addx(p_xid number, p_xame varchar2) AS
BEGIN
INSERT INTO x VALUES (p_xid,p_xame);
END;
CREATE OR REPLACE procedure addY(p_yid number, p_yname varchar2) AS
BEGIN
INSERT INTO Y VALUES (p_yid,p_yname, 0);
END;
set serveroutput on
prompt TESTING ADD X rows
begin
addX(1,'one');
addX(2,'two');
addX(3,'three');
addX(4,'four');
EXCEPTION
WHEN others THEN
dbms_output.put_line(SQLCODE || ' ' || substr(SQLERRM, 1, 200));
END;
set serveroutput on
prompt ADD Y ROWS;
BEGIN
--Test successfully add Y rows
addY(21,'twoone');
addY(22,'twotwo');
addY(23,'twothree');
addY(24,'twofour');
EXCEPTION
WHEN others THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE || ' ' || SUBSTR(SQLERRM, 1, 200));
END;
[Updated on: Fri, 30 March 2012 16:55] Report message to a moderator
|
|
|
Re: SQL Developer query [message #549479 is a reply to message #549475] |
Fri, 30 March 2012 19:28 |
|
BlackSwan
Messages: 26766 Registered: January 2009 Location: SoCal
|
Senior Member |
|
|
THANKS! for decent test case.
So what do you think & see?
17:27:21 SQL> @xy
17:27:25 SQL> drop table X cascade constraints;
Table dropped.
17:27:25 SQL> CREATE TABLE X(
17:27:25 2 xid NUMBER PRIMARY KEY,
17:27:25 3 xname VARCHAR2(100) );
Table created.
17:27:25 SQL>
17:27:25 SQL> drop table y cascade constraints;
Table dropped.
17:27:25 SQL> CREATE TABLE Y(
17:27:25 2 yid NUMBER PRIMARY KEY,
17:27:25 3 yname varchar2(100),
17:27:25 4 maxqty number );
Table created.
17:27:25 SQL>
17:27:25 SQL> CREATE OR REPLACE procedure addx(p_xid number, p_xame varchar2) AS
17:27:25 2 BEGIN
17:27:25 3 INSERT INTO x VALUES (p_xid,p_xame);
17:27:25 4 END;
17:27:25 5 /
Procedure created.
17:27:26 SQL> CREATE OR REPLACE procedure addY(p_yid number, p_yname varchar2) AS
17:27:26 2 BEGIN
17:27:26 3 INSERT INTO Y VALUES (p_yid,p_yname, 0);
17:27:26 4 END;
17:27:26 5 /
Procedure created.
17:27:26 SQL> set serveroutput on
17:27:26 SQL> prompt TESTING ADD X rows
TESTING ADD X rows
17:27:26 SQL> begin
17:27:26 2 addX(1,'one');
17:27:26 3 addX(2,'two');
17:27:26 4 addX(3,'three');
17:27:26 5 addX(4,'four');
17:27:26 6 END;
17:27:26 7 /
PL/SQL procedure successfully completed.
17:27:26 SQL> set serveroutput on
17:27:26 SQL> prompt ADD Y ROWS;
ADD Y ROWS
17:27:26 SQL> BEGIN
17:27:26 2 --Test successfully add Y rows
17:27:26 3 addY(21,'twoone');
17:27:26 4 addY(22,'twotwo');
17:27:26 5 addY(23,'twothree');
17:27:26 6 addY(24,'twofour');
17:27:26 7 END;
17:27:26 8 /
PL/SQL procedure successfully completed.
17:27:26 SQL>
|
|
|
|
|
|