oracle - SERVEROUTPUT shows results one after another execution -
when execute following trigger code compiled. after inserting data, serveroutput says '1 row inserted' trigger result ('user example has insrted data') didn't displayed.
then after execution of pl/sql previous trigger result appears on display. should solve issue?
here trigger , insertion command , results,
/ set serveroutput on; create or replace trigger btr_superheros before insert on superheros each row enable declare v_user varchar2(30); begin select user v_user dual; dbms_output.enable(); dbms_output.put_line('user:' ||v_user||' has inserted data'); end; /
result - trigger btr_superheros compiled
insert superheros values('superman');
result - 1 row inserted. (didn't shows dbms_output)
you need set serveroutput on
in client application (sql*plus, sql developer etc) in session run statement, otherwise won't know want fetch , display output buffer when statement completes. set server output on
prior creating trigger client setting , doesn't set permanently trigger.
please confirm whether test case run single session, this:
sql*plus: release 12.1.0.1.0 production on tue aug 15 08:17:48 2017 copyright (c) 1982, 2013, oracle. rights reserved. last successful login time: tue aug 15 2017 08:14:08 +01:00 connected to: oracle database 12c enterprise edition release 12.1.0.1.0 - 64bit production partitioning, olap, advanced analytics , real application testing options sql> set serveroutput on; sql> sql> create or replace trigger btr_superheros 2 before insert on superheros 3 each row 4 enable 5 6 declare 7 v_user varchar2(30); 8 begin 9 select user v_user dual; 10 dbms_output.enable(); 11 dbms_output.put_line('user:' ||v_user||' has inserted data'); 12 end; 13 / trigger created. sql> insert superheros values('superman'); user:william has inserted data 1 row created.
note not recommended call dbms_output.enable
. the documentation:
you should avoid having application code invoke either disable procedure or enable procedure because subvert attempt of external tool sql*plus control whether or not display output.
you can assign values using assignment :=
operator instead of select into
statement. trigger therefore written as:
create or replace trigger btr_superheros before insert on superheros each row enable declare v_user user_users.username%type := sys_context('userenv', 'current_schema'); begin dbms_output.put_line('user: ' ||v_user||' inserted value '''||:new.name||''''); end; /
Emperor Casino Online – Sportsbook Review 2021 - Legalbet
ReplyDeleteEmperor 제왕카지노 Casino Online – Sportsbook Review vua nhà cái 2021 - Legalbet.co.kr offers the best sportsbook fun88 soikeotot in the country's borders.