Priority of pragma exception_init..
Hi All,
Suppose I am using pragma exception_init for NO_DATA_FOUND error,
and the variable I am using is "test_excp" in my stored procedure, in the exception section if I am using both the user defined exception and the system defined exception (i.e. when test_excp then and when NO_DATA_FOUND then ) then which exception will the engine pick?
This is not a business requirement but its a doubt on my part.
Please help me understanding this concept..
Thanks in advance!!
Bits
Confused yet?
Note that there is also a -100 no data found error in Oracle but it appears to be treated as an entirely separate exception (albeit with the same message), e.g.
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
SQL> DECLARE
2 e_no_data_found EXCEPTION;
3 PRAGMA EXCEPTION_INIT (e_no_data_found, -100);
4 BEGIN
5 RAISE e_no_data_found;
6 EXCEPTION
7 WHEN NO_DATA_FOUND THEN
8 RAISE_APPLICATION_ERROR (-20000, 'encountered NO_DATA_FOUND exception.', TRUE);
9 WHEN e_no_data_found THEN
10 RAISE_APPLICATION_ERROR (-20000, 'encountered e_no_data_found exception.', TRUE);
11 END;
12 /
DECLARE
ERROR at line 1:
ORA-20000: encountered e_no_data_found exception.
ORA-06512: at line 10
ORA-00100: no data found
SQL>
Similar Messages
-
How attend error in forms menu like pragma exception_init ?
hello,
I have problem with error in my menu. I created menu and I put code to my buttons in menu:for example execute_trigger('test');
I have some forms and if I am in another forms and call my button with execute_trigger('test');
I get error FRM-40700: No such trigger: test
Its ok because I have trigger in another block. But how to attend this error. I put pragma execption_init but not work
declare
text exception;
pragme exception_init(text,-40700);
begin
execute_trigger('test');
exception
when text then
message('its work');
end;
I create code like this in menu;
execute_trigger('test');
if form_failure then
message('its work');
end if;
end;
and this work but I get error FRM-40700: No such trigger: test and next message is 'its work'. How to turn off message from forms?? or like this message make like pragma...
regardsthanks for reply.
trigger exist but in another block.
I check system.message-level
thanks
I find another solution
I put procedure which verificate current_block and current_form and then call execute_trigger(). It's work
Edited by: user515960 on 2010-07-18 02:43 -
Pragma Exception_INIT- Doubt
Hi All
Why we are using Pragma Exception_INIT what is the purpose ?
Declare
e_MissingNull EXCEPTION;
PRAGMA EXCEPTION_INIT(e_MissingNull, -1400);
BEGIN
INSERT INTO Employees (employee_id) VALUES (NULL);
EXCEPTION
WHEN e_MissingNull then
DBMS_OUTPUT.put_line('ORA-1400 occurred');
END;when i give the above code i get
PL/SQL procedure successfully completed. ORA-1400 occurred
The same code when i try to give error message is ORA-1500 occurred
I get
ORA-01400: cannot insert NULL into ("XXI"."EMPLOYEES"."EMPLOYEE_ID")
ORA-06512: at line 6
why it happens?
And when i use try to get the error messgae to display Not valid instead of Zero_divide
Declare
I Number;
e_sample EXCEPTION;
PRAGMA EXCEPTION_INIT(e_sample, -5737);
BEGIN
select 1/0 Into I From Dual ; -- I know Zero_Divide Error i thought the changing this error in my style
EXCEPTION
WHEN e_smple then
DBMS_OUTPUT.put_line('ORA-5737 Not valid');
END;But the Result is
ORA-01476: divisor is equal to zero
Please let me know the purpose of and usage for Pragma Exception_INIT
Thank in advance
SureshYou must to issue:
SET SERVEROUTPUT ONto tell SQL*PLus to display DBMS_OUTPUT buffer:
SQL> Declare
2 e_MissingNull EXCEPTION;
3 PRAGMA EXCEPTION_INIT(e_MissingNull, -1400);
4 BEGIN
5 INSERT INTO Employees (employee_id) VALUES (NULL);
6 EXCEPTION
7 WHEN e_MissingNull then
8 DBMS_OUTPUT.put_line('ORA-1400 occurred');
9 END;
10 /
PL/SQL procedure successfully completed.
SQL> SET SERVEROUTPUT ON
SQL> Declare
2 e_MissingNull EXCEPTION;
3 PRAGMA EXCEPTION_INIT(e_MissingNull, -1400);
4 BEGIN
5 INSERT INTO Employees (employee_id) VALUES (NULL);
6 EXCEPTION
7 WHEN e_MissingNull then
8 DBMS_OUTPUT.put_line('ORA-1400 occurred');
9 END;
10 /
ORA-1400 occurred
PL/SQL procedure successfully completed.
SQL> Now about zero_divide. You are initializing exception e_sample with -5737, while zero_divide is -1476:
SQL> Declare
2 I Number;
3 e_sample EXCEPTION;
4 PRAGMA EXCEPTION_INIT(e_sample, -1476);
5 BEGIN
6 select 1/0 Into I From Dual ; -- I know Zero_Divide Error i thought the changing this error in my style
7 EXCEPTION
8 WHEN e_sample then
9 DBMS_OUTPUT.put_line('ORA-5737 Not valid');
10 END;
11 /
ORA-5737 Not valid
PL/SQL procedure successfully completed.
SQL> SY. -
HI,
I want log the ORA-00942 error through exception.
declare
v_no number;
v_error exception;
pragma exception_init(v_error,-942);
begin
select empno into v_no from notable;
exception
when v_error then
insert into log values('no table');
end;
when ever i execute the program ,instead of logging error in log table ..it is raising error that ' ORA-942 TABLE OR VIEW DOESN'T EXIST'. i want log this message in logtable instead of raising error
ThanksHi,
only a short addition/illustration to/of the idea provided by SY
-- Create Log-Table
drop table log;
Create table log ( msg varchar2(4000 char));
drop table notable;
-- P compiles without table "NOTABLE" because of the use of dynamic sql see
-- Solomon Yakobsons post above
create or replace
procedure p
as
v_no number;
v_stmt varchar2(2000) := 'select empno from notable';
v_error exception;
pragma exception_init(v_error,-942);
begin
EXECUTE IMMEDIATE v_stmt into v_no;
insert into log values('j = '|| (nvl(to_char(v_no), '<<NULL>>')));
exception
when v_error then
insert into log values('no table');
-- you somehow need the following commit to make the changes in the log-table permanent;
-- other way could be combining this method with autonomous transactions
commit;
when others then
insert into log values(substr(dbms_utility.format_error_stack,1,4000));
-- commit; /*????*/
end;
-- 1. table "NOTABLE" doesn't exist => "no table" in log-table
truncate table log;
exec p;
select * from log;
-- 2. table "NOTABLE" exists but is empty => "ORA-01403: no data found"
create table notable (empno Number);
truncate table log;
-- writes log-message "ORA-01403: no data found" into log-table
exec p;
select * from log;
-- 3. one row in "NOTABLE"; "all is well"; here "j = 1"
-- insert first row into notable
insert into notable (empno) values (1);
commit; -- not needed because of the following truncate
-- writes value of the selection into the log-table
truncate table log;
exec p;
select * from log;
-- 4. two rows in notable => "ORA-01422: exact fetch returns more than requested number of rows"
-- insert second row
insert into notable (empno) values (2);
commit;
truncate table log;
-- writes error
exec p;
select * from log;So the "COMMIT" in the exception-handler may cause some trouble, if you just write without commiting here,
a calling stored procedure might rollback your changes, which will be very misleading. The use of AUTONOMOUS TRANSACTIONS
could get complicated too, please be careful here.
See [url http://tkyte.blogspot.de/search?q=autonomous+transactions] Tom Kyte Blog about AUTONOMOUS TRANSACTIONS, EXCEPTION WHEN OTHERS, ... why and when autonomous transactions can help you and if you should rethink your strategy about not reraising the error. Your business logic is broken in this case, isn't it? So why carry on?
Regards
stratmo
PS: User Profile for 920033 Handle: 920033
Status Level: Newbie
Registered: Mar 10, 2012
Total Posts: 52
Total Questions: 20 (20 unresolved)
>
Uuuups, seems that there is some work to do for you;-) -
PRAGMA EXCEPTION_INIT (bulk_errors, -24381);
PRAGMA EXCEPTION_INIT (bulk_errors, -24381);
Can u plz explain me what is use of this statement if I declare like this. And also tell me use of the PRAGMAIn PL/SQL, sometimes it becomes necessary to raise a predefined Oracle error
as an exception. Depending on the error number, there are some predefined
EXCEPTIONs that can be raised. These EXCEPTIONs are defined in package
STANDARD and are globally available. Other errors do not have predefined
EXCEPTIONs declared. In order to associate a predefined error number to an
EXCEPTION, use the PRAGMA EXCEPTION_INIT. When using PRAGMA EXCEPTION_INIT,
remember that all Oracle error numbers with exception of 1403 and 100 are
negative.
Once the EXCEPTION has been aliased, the EXCEPTION can then be raised. -
Srw package throwing PRAGMA exception_init(SPECIFY_PROTOCOL, -20002)
I've added srw.ADD_PARAMETER ( plRepParam, 'server_protocol', 'HTTP/1.1' ); to no avail. Any ideas?
Twas muppetry on my part, I had missed http:// from my gateway param setting.
-
PRAGMA forcing integral number
The following line of code won't compile,
PRAGMA EXCEPTION_INIT(XCPT_invalid_param, ERR_invalid_fax_code);however, this will:
PRAGMA EXCEPTION_INIT(XCPT_invalid_param, -20001);ERR_invalid_fax_code is declared as
ERR_invalid_fax_code CONSTANT INTEGER := -20001;What to I do to make it accept a constant var, instead of an integral number?The second argument to EXCEPTION_INIT must be a literal.
I don't know why, that's just the way it is.
See:
http://download-east.oracle.com/docs/cd/B10501_01/server.920/a96525/pcmus.htm#1001616 -
Differnce between exception_init and init_exception
I have declared an usernamed exception and wanted to call...
I came to know that these can be called by using two of the below -
Pragma Exception_init
Pragma Init_Exception
What is the differnce between[b] exception_init and init_exception ? And where they can be used ?
awating for your rresponse ..!Oracle Database 10g Enterprise Edition Release 10.2.0.3.0:
SQL>declare
2 my_exception exception;
3 pragma exception_init(my_exception, -20101);
4 begin
5 raise my_exception;
6 exception
7 when my_exception then
8 dbms_output.put_line(sqlerrm);
9 end;
10 /
ORA-20101:
PL/SQL procedure successfully completed.
SQL>declare
2 my_exception exception;
3 pragma init_exception(my_exception, -20101);
4 begin
5 raise my_exception;
6 exception
7 when my_exception then
8 dbms_output.put_line(sqlerrm);
9 end;
10 /
pragma init_exception(my_exception, -20101);
ERROR at line 3:
ORA-06550: line 3, column 11:
PLS-00127: Pragma INIT_EXCEPTION is not a supported pragma -
Morning,
Would some one please review this code below? I am trying to capture the oracle error table or view does not exist -00942 but it does not seem to want to work. What am I typing wrong?? It throws the error instead of it being handle within the exception section. This table is not available when I run it in 9i.
I simplified the select statement.
declare
table_view_not_exist EXCEPTION;
PRAGMA EXCEPTION_INIT(table_view_not_exist, -00942);
begin
select end_time from dba_optstat_operations;
EXCEPTION
WHEN table_view_not_exist
THEN
DBMS_OUTPUT.PUT_LINE('PLEASE RUN ANALYZE MANUALLY');
end;
Any help in this matter would be appreciated.
Thanks in advance and have a great day.
alThe code cannot compile if the table isn't present.
Try this:
DECLARE
table_view_not_exist EXCEPTION;
PRAGMA EXCEPTION_INIT(table_view_not_exist, -942);
v_end_time DATE;
BEGIN
EXECUTE IMMEDIATE 'SELECT end_time FROM dba_optstat_operations'
INTO v_end_time;
DBMS_OUTPUT.PUT_LINE('End date: ' || TO_CHAR(v_end_time,'YYYY-MM-DD HH24:MI:SS'));
EXCEPTION
WHEN table_view_not_exist THEN
dbms_output.put_line('Please run analyze manually');
END; -
Trapping in APForm Trig via PRAGMA EXCEPTION
hi,
I can trap 06052 errors in report 6i (After pform trig)
but not -01843,-01847 and a few others relating to date format input mask errors. Anyone know why?
Thanks.
N.
Here's how I do it: (in after pform trig)
date_invalid EXCEPTION;
PRAGMA EXCEPTION_INIT (date_invalid, -01843);
BEGIN
EXCEPTION
when date_invalid THEN srw.message('Date must in Format ''DD-MON-YYYY'' !');
RETURN ( FALSE );
END;.
-
I have this error I was hoping someone might be able to point me in the right direction. Basically I need to dequeue messages from a queue in batch (as one at a time will be too slow). The follow error is related to my TYPE I've defined at schema level. I think its the XMLType is causing me this problem as when I use a normal Object type define with columns I can get the dequeue_Array to work fine !
Any help would be appreciated. Thanks.
/* Current DDL for Queue, QTable and Type */
CREATE OR REPLACE TYPE REQUEST_XML_QUEUE_TYPE AS OBJECT (REQUEST_XML XMLTYPE);
BEGIN
DBMS_AQADM.CREATE_QUEUE_TABLE (
queue_table => 'REQUEST_XML_QUEUE_TABLE',
queue_payload_type => 'REQUEST_XML_QUEUE_TYPE',
storage_clause => NULL,
sort_list => 'priority,enq_time',
multiple_consumers => FALSE,
message_grouping => DBMS_AQADM.TRANSACTIONAL ,
comment => 'Request Queue Table for storing XML inputs for BPs',
auto_commit => TRUE,
primary_instance => 0,
secondary_instance => 0,
compatible => NULL,
secure => FALSE);
END;
BEGIN
DBMS_AQADM.CREATE_QUEUE (
queue_name => 'REQUEST_XML_QUEUE',
queue_table => 'REQUEST_XML_QUEUE_TABLE',
queue_type => DBMS_AQADM.NORMAL_QUEUE,
max_retries => NULL,
retry_delay => 0,
retention_time => 0,
dependency_tracking => FALSE,
comment => 'Request XML Queue',
auto_commit => TRUE);
END;
BEGIN
DBMS_AQADM.START_QUEUE(
queue_name => 'REQUEST_XML_QUEUE',
enqueue => TRUE,
dequeue => TRUE);
END;
/* I created the following to test DBMS_AQ.DEQUEUE_ARRAY */
CREATE TYPE REQUEST_XML_Q_TYPE_ARR AS TABLE OF REQUEST_XML_QUEUE_TYPE;
DECLARE
r_dequeue_options DBMS_AQ.DEQUEUE_OPTIONS_T;
nt_msg_properties DBMS_AQ.MESSAGE_PROPERTIES_ARRAY_T := DBMS_AQ.MESSAGE_PROPERTIES_ARRAY_T();
nt_payloads REQUEST_XML_Q_TYPE_ARR := REQUEST_XML_Q_TYPE_ARR();
nt_msg_ids DBMS_AQ.MSGID_ARRAY_T := DBMS_AQ.MSGID_ARRAY_T();
v_dequeued_cnt PLS_INTEGER;
v_dequeue_batch PLS_INTEGER := 150;
v_continue BOOLEAN := TRUE;
x_timeout EXCEPTION;
PRAGMA EXCEPTION_INIT(x_timeout, -25228);
BEGIN
dbms_output.put_line('Inside DEQUEUE proc...');
nt_payloads.EXTEND(v_dequeue_batch);
nt_msg_properties.EXTEND(v_dequeue_batch);
dbms_output.put_line('Starting While Loop...');
/* Dequeue all messages in batches... */
WHILE v_continue LOOP
BEGIN
dbms_output.put_line('Starting Dequeue ...');
v_dequeued_cnt := DBMS_AQ.DEQUEUE_ARRAY(
queue_name => 'REQUEST_MSG_QUEUE',
dequeue_options => r_dequeue_options,
array_size => v_dequeue_batch,
message_properties_array => nt_msg_properties,
payload_array => nt_payloads,
msgid_array => nt_msg_ids);
DBMS_OUTPUT.PUT_LINE('Dequeued [' || TO_CHAR(v_dequeued_cnt) || '] messages.');
/* other code ..... */
v_continue := (v_dequeued_cnt = v_dequeue_batch);
COMMIT;
EXCEPTION
/* Handle exit scenario two from the notes above... */
WHEN x_timeout THEN
DBMS_OUTPUT.PUT_LINE('No more messages to dequeue.');
v_continue := FALSE;
END;
END LOOP;
dbms_output.put_line('Outside While Loop...');
END;
/* output from code block above when run */
SQL>
Inside DEQUEUE proc...
Starting While Loop...
Starting Dequeue ...
DECLARE
ERROR at line 1:
ORA-25215: user_data type and queue type do not match
ORA-06512: at "SYS.DBMS_AQ", line 619
ORA-06512: at line 24
SQL>I know its being sometime since you posted this message but can you tell me if you got it resolved. I too am experiencing the same problem.
Many thanks in advance. -
After Update Trigger not triggering for first update
Hi All,
I have written a Trigger on AP_SUPPLIERS table to update AP_SUPPLIER_SITES_ALL when payment priority gets updated on AP_SUPPLIERS table. Trigger calls a pragma autonomous procedure after update happens, and updates sites table. We are on R12 (12.1.3) with DB 11.2.0.3.0
Somehow this is not working for the first update, after that for every update it is working. Any idea why this might be happening?
Trigger Code:
CREATE OR REPLACE TRIGGER XX_AP_SUPPLIER_SIT_UPD_SYNC
AFTER UPDATE
ON AP.AP_SUPPLIERS
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
l_vendor_id NUMBER;
l_paym_priority NUMBER;
BEGIN
XX_AP_SUPSITE_UPDATE(:NEW.PAYMENT_PRIORITY, :NEW.VENDOR_ID);
EXCEPTION
WHEN OTHERS THEN
RAISE;
END XX_AP_SUPPLIER_SIT_UPD_SYNC;
Procedure Code:
CREATE OR REPLACE PROCEDURE APPS.XX_AP_SUPSITE_UPDATE (p_payment_priority IN NUMBER,p_vendor_id IN NUMBER) AS
PRAGMA AUTONOMOUS_TRANSACTION;
ex_custom EXCEPTION;
PRAGMA EXCEPTION_INIT( ex_custom, -20001 );
BEGIN
UPDATE AP_SUPPLIER_SITES_ALL
SET PAYMENT_PRIORITY =p_payment_priority
WHERE VENDOR_ID = p_vendor_id;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
raise_application_error( -20001, 'Error while updating payment priority on Site '||SQLERRM );
END XX_AP_SUPSITE_UPDATE;Thanks for your replies Saubhik/VT,
now my trigger is compiled. but is not triggering. pl help me to resolve .....
create or replace
TRIGGER AUDIT_DEV.trg2
AFTER DELETE OR UPDATE OF EMP_STATUS ON AUDIT_DEV.AUDIT_PERSONS
FOR EACH ROW
declare
OSUSER varchar2(30);
MACHINE varchar2(30);
logon_time date;
db_user varchar2(30);
USERNAME VARCHAR2(30);
EMP_USER_MODIFIED AUDIT_PERSONS.EMP_USER_MODIFIED%TYPE;
EMP_DATE_MODIFIED AUDIT_PERSONS.EMP_DATE_MODIFIED%TYPE;
EMP_SK AUDIT_PERSONS.EMP_SK%TYPE;
EMP_ID AUDIT_PERSONS.EMP_ID%TYPE;
EMP_NAME AUDIT_PERSONS.EMP_NAME%TYPE;
EMP_RESIGNATION_DATE AUDIT_PERSONS.EMP_RESIGNATION_DATE%TYPE;
BEGIN
select username,osuser,machine,logon_time into db_user,osuser,machine,logon_time from v$session where sid=(select sid from v$mystat where rownum=1);
INSERT INTO AUDIT_DEV.AUDIT_PERSONS_LOG (EMP_USER_MODIFIED,EMP_DATE_MODIFIED,EMP_SK,EMP_ID,EMP_NAME,EMP_RESIGNATION_DATE,EMP_STATUS_OLD,EMP_STATUS_NEW,osuser,db_user,machine)
VALUES(EMP_USER_MODIFIED,EMP_DATE_MODIFIED,EMP_SK,EMP_ID,EMP_NAME,EMP_RESIGNATION_DATE,:old.EMP_status,:new.EMP_status,osuser,db_user,machine );
COMMIT;
END;
09:59:06 AUDIT_DEV@dev>UPDATE AUDIT_DEV.AUDIT_PERSONS SET EMP_STATUS='TEST' WHERE EMP_ID='4234';
EMP_STATUS
TEST
1 row selected.
Elapsed: 00:00:00.01
10:00:03 AUDIT_DEV@dev>commit;
Commit complete.
Elapsed: 00:00:00.01
10:00:17 AUDIT_DEV@dev>select * from AUDIT_persons_log;
no rows selected
Elapsed: 00:00:00.00
10:00:17 AUDIT_DEV@dev>
Edited by: Abk on Nov 4, 2010 10:42 AM -
Dbms_scheduler - dbms_aq - dbms_aqadm - event driven job runs only once/sec
hi, i tried here to process events with 2 jobs... surprisingly i had to call dbms_lock.sleep(1) to be able to enqueue events
at inserts in a row ... even more surprisingly the enqueuing doesn't function if the processing (prc_evsched) lasts some seconds...
how must the code be changed to be able to enqueue all events after the inserts without any sleep()?
and how must the code be changed to be able to enqueue all events with a proc (prc_evsched) running longer?
thanx in advance for your help!
--evsched
h4.
--to remove all test-objects
h4.
--test table
h4.
--define the object type to act as the payload for the queue
h4.
--creating the event queue
h4.
--creating the proc for the prog/job
h4.
--creating the proc for the prog/job
h4.
--creating the program
h4.
--creating the first job (for parallel execution)
h4.
--creating the second job (for parallel execution)
h4.
--test block
h4.
--test scenarios/results
h4.
--to remove all test-objects
DECLARE
exc_ora_27475 EXCEPTION; --ora-27475: <job_name> muss job sein
PRAGMA EXCEPTION_INIT (exc_ora_27475, -27475);
exc_ora_27476 EXCEPTION; --ora-27476: <program_name> ist nicht vorhanden
PRAGMA EXCEPTION_INIT (exc_ora_27476, -27476);
exc_ora_24010 EXCEPTION; --ORA-24010: QUEUE SYSGIS.EVENT_QUEUE ist nicht vorhanden
PRAGMA EXCEPTION_INIT (exc_ora_24010, -24010);
exc_ora_24002 EXCEPTION; --ORA-24002: QUEUE_TABLE SYSGIS.EVENT_QUEUE_TAB ist nicht vorhanden
PRAGMA EXCEPTION_INIT (exc_ora_24002, -24002);
exc_ora_4043 EXCEPTION; --ORA-04043: Objekt T_EVENT_QUEUE_PAYLOAD ist nicht vorhanden
PRAGMA EXCEPTION_INIT (exc_ora_4043, -4043);
exc_ora_942 EXCEPTION; --ORA-00942: Tabelle oder View nicht vorhanden
PRAGMA EXCEPTION_INIT (exc_ora_942, -942);
exc_ora_2289 EXCEPTION; --ORA-02289: Sequence ist nicht vorhanden.
PRAGMA EXCEPTION_INIT (exc_ora_2289, -2289);
v_fpos PLS_INTEGER := 1;
BEGIN
v_fpos := 10;
BEGIN
--remove job
SYS.DBMS_SCHEDULER.DROP_JOB(job_name=> 'job_evsched', FORCE=>TRUE);
EXCEPTION WHEN exc_ora_27475 THEN NULL;
END;
v_fpos := 12;
BEGIN
--remove job
SYS.DBMS_SCHEDULER.DROP_JOB(job_name=> 'job_evsched_2', FORCE=>TRUE);
EXCEPTION WHEN exc_ora_27475 THEN NULL;
END;
v_fpos := 20;
BEGIN
--remove program
SYS.DBMS_SCHEDULER.DROP_PROGRAM(program_name=>'prg_evsched',FORCE=>TRUE);
EXCEPTION WHEN exc_ora_27476 THEN NULL;
END;
v_fpos := 30;
BEGIN
-- stop the event queue.
DBMS_AQADM.stop_queue (queue_name => 'evsched_event_queue');
EXCEPTION WHEN exc_ora_24010 THEN NULL;
END;
v_fpos := 40;
BEGIN
-- drop the event queue.
DBMS_AQADM.drop_queue (queue_name => 'evsched_event_queue');
EXCEPTION WHEN exc_ora_24010 THEN NULL;
END;
v_fpos := 50;
BEGIN
-- Remove the queue table.
DBMS_AQADM.drop_queue_table(queue_table => 'tab_evsched_event_queue');
EXCEPTION WHEN exc_ora_24002 THEN NULL;
END;
v_fpos := 60;
BEGIN
-- remove type
EXECUTE IMMEDIATE 'DROP TYPE typ_evsched_payload';
EXCEPTION WHEN exc_ora_4043 THEN NULL;
END;
v_fpos := 70;
BEGIN
-- remove table
EXECUTE IMMEDIATE 'DROP TABLE tab_evsched';
EXCEPTION WHEN exc_ora_942 THEN NULL;
END;
v_fpos := 80;
BEGIN
-- remove sequence
EXECUTE IMMEDIATE 'DROP SEQUENCE seq_evsched';
EXCEPTION WHEN exc_ora_2289 THEN NULL;
END;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('v_fpos='||v_fpos);
END;
h4.
--test table
CREATE TABLE tab_evsched
( id NUMBER
, sys_date DATE
, status VARCHAR2(1)
, processed VARCHAR2(1) DEFAULT 'N'
, processed_by varchar2(128)
GRANT DELETE, INSERT, SELECT, UPDATE ON tab_evsched TO PUBLIC
CREATE SEQUENCE seq_evsched
h4.
--define the object type to act as the payload for the queue
CREATE OR REPLACE TYPE typ_evsched_payload AS OBJECT
( event_name VARCHAR2(30)
, tab_evsched_id NUMBER
, daterf DATE
h4.
--creating the event queue
BEGIN
-- Create a queue table to hold the event queue.
DBMS_AQADM.create_queue_table
( queue_table => 'tab_evsched_event_queue'
, queue_payload_type => 'typ_evsched_payload'
, multiple_consumers => TRUE
, COMMENT => 'Queue Table For Event Messages'
-- Create the event queue.
DBMS_AQADM.create_queue
( queue_name => 'evsched_event_queue'
, queue_table => 'tab_evsched_event_queue'
, queue_type => DBMS_AQADM.NORMAL_QUEUE
, max_retries => 0
, retry_delay => 0
, dependency_tracking => FALSE
, comment => 'Test Object Type Queue'
, auto_commit => FALSE
-- Start the event queue.
DBMS_AQADM.start_queue
( queue_name => 'evsched_event_queue'
END;
h4.
--creating the proc for the prog/job
CREATE OR REPLACE PROCEDURE prc_evsched
( p_message IN typ_evsched_payload
, p_job_name IN VARCHAR2
IS
BEGIN
UPDATE tab_evsched
SET processed = 'J'
, processed_by = p_job_name
, sys_date = p_message.daterf
WHERE 1=1
AND id = p_message.tab_evsched_id
dbms_lock.sleep(5); --#sleep-1#
COMMIT;
END prc_evsched;
h4.
--creating the program
DECLARE
exc_ora_27476 EXCEPTION; --ora-27476: <program_name> ist nicht vorhanden
PRAGMA EXCEPTION_INIT (exc_ora_27476, -27476);
BEGIN
BEGIN
SYS.DBMS_SCHEDULER.DROP_PROGRAM(program_name=>'prg_evsched',FORCE=>TRUE);
EXCEPTION
WHEN exc_ora_27476 THEN
NULL;
END;
SYS.DBMS_SCHEDULER.CREATE_PROGRAM
( program_name => 'prg_evsched'
, program_type => 'STORED_PROCEDURE'
, program_action => '"SYSGIS"."PRC_EVSCHED"'
, number_of_arguments => 2
, enabled => FALSE
, comments => 'Program-Komponent für den Test von DBMS_SCHEDULER'
--event message as the first param to prc_evsched
DBMS_SCHEDULER.DEFINE_METADATA_ARGUMENT
( program_name => 'prg_evsched'
, argument_position => 1
, metadata_attribute => 'EVENT_MESSAGE'
--name of the job as the second param to prc_evsched
SYS.DBMS_SCHEDULER.define_program_argument
( program_name => 'prg_evsched'
, argument_name => 'p_job_name'
, argument_position => 2
, argument_type => 'VARCHAR2'
, default_value => 'dummy'
--enable program
SYS.DBMS_SCHEDULER.ENABLE(NAME=>'prg_evsched');
END;
h4.
--creating the first job (for parallel execution)
DECLARE
exc_ora_27475 EXCEPTION; --ora-27475: <job_name> muss job sein
PRAGMA EXCEPTION_INIT (exc_ora_27475, -27475);
BEGIN
BEGIN
--remove job
SYS.DBMS_SCHEDULER.DROP_JOB(job_name=> 'job_evsched', FORCE=>TRUE);
EXCEPTION WHEN exc_ora_27475 THEN NULL;
END;
DBMS_SCHEDULER.create_job
( job_name => 'job_evsched'
, program_name => 'prg_evsched'
, start_date => SYSTIMESTAMP
, event_condition => 'tab.user_data.event_name = ''MYEVENT'''
, queue_spec => 'evsched_event_queue'
, auto_drop => FALSE
, enabled => FALSE
SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE
( job_name => 'job_evsched'
, argument_name => 'p_job_name'
, argument_value => 'job_evsched'
SYS.DBMS_SCHEDULER.ENABLE(NAME=>'job_evsched');
END;
h4.
--creating the second job (for parallel execution)
DECLARE
exc_ora_27475 EXCEPTION; --ora-27475: <job_name> muss job sein
PRAGMA EXCEPTION_INIT (exc_ora_27475, -27475);
BEGIN
BEGIN
--remove job
SYS.DBMS_SCHEDULER.DROP_JOB(job_name=> 'job_evsched_2', FORCE=>TRUE);
EXCEPTION WHEN exc_ora_27475 THEN NULL;
END;
DBMS_SCHEDULER.create_job
( job_name => 'job_evsched_2'
, program_name => 'prg_evsched'
, start_date => SYSTIMESTAMP
, event_condition => 'tab.user_data.event_name = ''MYEVENT'''
, queue_spec => 'evsched_event_queue'
, auto_drop => FALSE
, enabled => FALSE
SYS.DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE
( job_name => 'job_evsched_2'
, argument_name => 'p_job_name'
, argument_value => 'job_evsched_2'
SYS.DBMS_SCHEDULER.ENABLE(NAME=>'job_evsched_2');
END;
h4.
--test block
DECLARE
PROCEDURE pr_ins_tab_evsched
( p_id IN NUMBER
, p_status IN VARCHAR2
IS
BEGIN
INSERT INTO tab_evsched(id,status) VALUES (p_id, p_status);
COMMIT;
--enqueue the MYEVENT-event
IF p_status = 'M' THEN
--enqueue works in 1sekunden-taktung.... !?
dbms_lock.sleep(1); --#sleep-2#
DECLARE
v_enqueue_options DBMS_AQ.enqueue_options_t;
v_message_properties DBMS_AQ.message_properties_t;
v_message_handle RAW(16);
v_queue_msg typ_evsched_payload;
BEGIN
v_queue_msg := typ_evsched_payload
( event_name => 'MYEVENT'
, tab_evsched_id => p_id
, daterf => SYSDATE
v_enqueue_options.VISIBILITY := DBMS_AQ.ON_COMMIT;
v_enqueue_options.delivery_mode := DBMS_AQ.PERSISTENT;
v_message_properties.PRIORITY := 1;
v_message_properties.DELAY := DBMS_AQ.NO_DELAY;
v_message_properties.EXPIRATION := DBMS_AQ.NEVER;
v_message_properties.CORRELATION := 'TEST MESSAGE';
DBMS_AQ.enqueue
( queue_name => 'evsched_event_queue'
, enqueue_options => v_enqueue_options
, message_properties => v_message_properties
, payload => v_queue_msg
, msgid => v_message_handle
END;
END IF;
COMMIT;
END pr_ins_tab_evsched;
BEGIN
DELETE tab_evsched;
pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
pr_ins_tab_evsched (seq_evsched.NEXTVAL,'M');
END;
SELECT * FROM tab_evsched ORDER BY id;
SELECT * FROM sysgis.tab_evsched_event_queue;
h4.
--test scenarios/resultsh
h5.
--test results #sleep-1#=5, #sleep-2#=0
--job (job_evsched) runs only once, only the first event is enqued/processed
ID SYS_DATE STATUS PROCESSED PROCESSED_BY
9 22.03.2012 17:00:41 M J job_evsched
10 (Null) M N (Null)
11 (Null) M N (Null)
12 (Null) M N (Null)
13 (Null) M N (Null)
14 (Null) M N (Null)
15 (Null) M N (Null)
16 (Null) M N (Null)
h5.
--test results #sleep-1#=0, #sleep-2#=1
--jobs (job_evsched/job_evsched2) run alternately, every events are enqued/processed
ID SYS_DATE STATUS PROCESSED PROCESSED_BY
25 22.03.2012 17:04:31 M J job_evsched_2
26 22.03.2012 17:04:32 M J job_evsched_2
27 22.03.2012 17:04:33 M J job_evsched
28 22.03.2012 17:04:34 M J job_evsched_2
29 22.03.2012 17:04:35 M J job_evsched_2
30 22.03.2012 17:04:36 M J job_evsched_2
31 22.03.2012 17:04:37 M J job_evsched
32 22.03.2012 17:04:38 M J job_evsched_2
h5.
--test results #sleep-1#=5, #sleep-2#=1
--jobs (job_evsched/job_evsched2) run alternately, only two events are enqued/processed
ID SYS_DATE STATUS PROCESSED PROCESSED_BY
41 22.03.2012 17:07:42 M J job_evsched_2
42 (Null) M N (Null)
43 (Null) M N (Null)
44 (Null) M N (Null)
45 (Null) M N (Null)
46 (Null) M N (Null)
47 22.03.2012 17:07:48 M J job_evsched
48 (Null) M N (Null)
*/hi, thank you for your (fast) answer! that is the solution to my problem!
now i have a follow-up question:
i've got a procedure, that runs between 1 and 2 minutes long. unlimited running lightweight jobs
would freeze the db...
how can the count of the parallel running lightweight-jobs be limited?
according to the documentation it is not possible:
There is no explicit limit to the number of lightweight jobs that can run simultaneously to process multiple instances of the event.
However, limitations may be imposed by available system resources.
could you explain to me, what it (...available system recources...) means?
eventually what i would like to have: max. two parallel running (lightweight) jobs....
thank you in advance, bye, á
ps: can i attach a file to the post anyway?
Edited by: user4786904 on 23.03.2012 07:22 -
DBSM_AQ SORT_LIST problem, timestamp is ignored.
Hello,
I am using dbms_aq to enqueue and dequeue data. The sort list on the queue table is 'PRIORITY,ENQ_TIME'
I am seeing that the ENQ_TIME is ignored when two records are enqueued in the same second but with different timestamp. I am not using any dequeue_condition
PRIORITY ENQUEUE_TIME DEQUEUE_TIME
Record1 1003 12/11/2014 1:43:35.084026000 PM 12/11/2014 1:43:36.656810000 PM
Record2 1003 12/11/2014 1:43:35.801906000 PM 12/11/2014 1:43:36.509805000 PM <--- Dequeued first
I have checked the documentation, but could not find any information that this will be ignored. This is randomly happening some times.
Here is my code, And thanks in advance,
BEGIN
DBMS_AQADM.CREATE_QUEUE_TABLE (queue_table => 'mpi_aqadm.qtab_message',
queue_payload_type => 'mpi_aqadm.typ_message',
sort_list => 'PRIORITY,ENQ_TIME',
COMMENT => 'Queue table for message Sync');
END;
BEGIN
DBMS_AQADM.CREATE_QUEUE (queue_name => 'mpi_aqadm.aq_message',
queue_table => 'mpi_aqadm.qtab_message',
max_retries => 0,
retry_delay => 60,
COMMENT => 'Advanced queue for message Sync');
END;
BEGIN
DBMS_AQADM.START_QUEUE (queue_name => 'mpi_aqadm.aq_message');
END;
--Enqueue Code
PROCEDURE prcenqueue (pinPriorityKey IN NUMBER, pinmessagekey IN NUMBER)
IS
lvModuleId CONSTANT VARCHAR2 (20) := 'PDR 1.01';
ltypPdrSync mpi_aqadm.typ_message;
ltypEnqueueOptions DBMS_AQ.ENQUEUE_OPTIONS_T;
ltypMessageProperties DBMS_AQ.MESSAGE_PROPERTIES_T;
lrMsgID RAW (16);
lvYrMonthDay NUMBER (6) := TO_NUMBER (TO_CHAR (SYSDATE, 'YYMMDD'));
BEGIN
ltypPdrSync := mpi_aqadm.typ_message(pinmessagekey);
ltypMessageProperties.priority := lvYrMonthDay || pinPriorityKey;
DBMS_AQ.ENQUEUE (queue_name => 'mpi_aqadm.aq_message',
enqueue_options => ltypEnqueueOptions,
message_properties => ltypMessageProperties,
payload => ltypPdrSync,
msgid => lrMsgID);
END;
-- Dequeue Data
/* Formatted on 3/2/2015 5:49:13 PM (QP5 v5.252.13127.32847) */
PROCEDURE prcdequeue
IS
dopt DBMS_AQ.DEQUEUE_OPTIONS_T;
mprop DBMS_AQ.MESSAGE_PROPERTIES_T;
msg RAW (16);
no_message EXCEPTION;
fetch_timeout EXCEPTION;
PRAGMA EXCEPTION_INIT (NO_MESSAGE, -25254);
PRAGMA EXCEPTION_INIT (FETCH_TIMEOUT, -25228);
get_data mpi_aqadm.typ_message;
BEGIN
dopt.WAIT := DBMS_AQ.NO_WAIT;
dopt.navigation := DBMS_AQ.FIRST_MESSAGE;
dopt.dequeue_mode := DBMS_AQ.REMOVE;
DBMS_AQ.DEQUEUE (queue_name => 'MPI_AQADM.aq_message',
dequeue_options => dopt,
message_properties => mprop,
payload => get_data,
msgid => msg);
prcprocessmessage (get_data.pinmessagekey);
END;
Thanks,
G.I also see this in documentation
If several messages are enqueued in the same second, then they all have the same enq_time. In this case the order in which messages are dequeued depends on step_no, a variable that is monotonically increasing for each message that has the same enq_time. There is no situation when both enq_timeand step_no are the same for two messages enqueued in the same session.
Do you think there is an issue around this? -
Error while creating a procedure (PLS-00103)
Hi Am create the follwing Procedure:-
create or replace PROCEDURE XL_SP_ROGUEUSERS (
csrresultset_inout IN OUT sys_refcursor,
intuserkey_in IN NUMBER,
strsortcolumn_in IN VARCHAR2,
strsortorder_in IN VARCHAR2,
intstartrow_in IN NUMBER,
intpagesize_in IN NUMBER,
intdocount_in IN NUMBER,
inttotalrows_out OUT NUMBER,
strfiltercolumnlist_in IN VARCHAR2,
strfiltercolumnvaluelist_in IN VARCHAR2,
strudfcolumnlist_in IN VARCHAR2,
strudfcolumnvaluelist_in IN VARCHAR2,
struserlogin_in IN VARCHAR2,
strfirstname_in IN VARCHAR2,
strlastname_in IN VARCHAR2,
strdate_in IN VARCHAR2
AS
BEGIN
DECLARE
whereclause VARCHAR2(8000);
select_stmt VARCHAR2(8000);
strColumnList VARCHAR2(4000);
strDateFormat VARCHAR2 (80);
strFromClause VARCHAR2(4000);
strWhereClause VARCHAR2(4000);
strOrderByClause VARCHAR2(2000);
intSortDirection_in PLS_INTEGER;
entsum varchar2(20) := 'Entitlements Summary';
str_row EXCEPTION;
do_cnt EXCEPTION;
no_logged_in_user EXCEPTION;
property_not_found EXCEPTION;
pragma exception_init(Str_row,-20001);
pragma exception_init(Do_cnt,-20002);
pragma exception_init(no_logged_in_user,-20003);
BEGIN
-- Throw exception if the start row or page size is either NULL or have
-- values less than or equal to zero
IF (intstartrow_in <= 0 OR intpagesize_in <= 0 OR intstartrow_in IS NULL OR intpagesize_in IS NULL)
THEN
RAISE str_row;
END IF;
-- Throw exception if the intdocount_in parameter is NULL or has a value
-- other than 0 and 1
IF intdocount_in NOT IN (0, 1, 2) OR intdocount_in IS NULL
THEN
RAISE do_cnt;
END IF;
-- Throw exception if the intuserkey_in (logged in user) parameter is NULL
IF intuserkey_in IS NULL or intuserkey_in <= 0
THEN
RAISE no_logged_in_user;
END IF;
-- Now, we start accumulating the whereclause based on the input
-- parameters, performing error checking along the way.
--Organization Permissioning.
/* whereclause := ' and usr.act_key IN (SELECT DISTINCT act2.act_key FROM '||
' act act2, aad, usg, ugp, usr usr5 '||
' WHERE act2.act_key = aad.act_key '||
' and aad.ugp_key = usg.ugp_key '||
' and ugp.ugp_key = usg.ugp_key'||
' and usg.usr_key = usr5.usr_key'||
' and usr5.usr_key = '||intuserkey_in||')'; */
IF strfiltercolumnlist_in IS NOT NULL AND
strfiltercolumnvaluelist_in IS NOT NULL THEN
whereclause := whereclause
|| xl_sfg_parseparams(strfiltercolumnlist_in,
strfiltercolumnvaluelist_in);
END IF;
IF struserlogin_in IS NOT NULL THEN
whereclause := whereclause
|| ' AND UPPER(usr.usr_login) LIKE '
|| UPPER (''''||struserlogin_in||'''')
|| ' ';
END IF;
IF strudfcolumnlist_in IS NOT NULL AND
strudfcolumnvaluelist_in IS NOT NULL THEN
whereclause := whereclause
|| xl_sfg_parseparams(strudfcolumnlist_in,
strudfcolumnvaluelist_in);
END IF;
-- Perform the count query and store the result in inttotalrows_out
inttotalrows_out := 0;
IF intdocount_in IN (1,2) THEN
EXECUTE IMMEDIATE ' select count(*) from((SELECT upper(rcd.RCD_VALUE) as "User ID" '|| ' FROM rce, obj, rcd, orf '||
' WHERE '||
' RCE_STATUS like 'No Match Found' '||
' AND ((orf.ORF_FIELDNAME like 'User ID') or (orf.ORF_FIELDNAME like 'User%Login')) '||
' AND rce.OBJ_KEY = obj.OBJ_KEY '||
' AND rce.RCE_KEY = rcd.RCE_KEY '||
' AND rcd.ORF_KEY = orf.ORF_KEY '||
' ) '||
' MINUS '||
' (SELECT usr.USR_LOGIN FROM usr '||
' WHERE '||
' usr.USR_STATUS like 'Active')) '||
whereclause INTO inttotalrows_out;
-- UI needs the SP to return result set always. The following is returned
-- when the indocount is 2 which does not return any result set but count
IF intdocount_in = 2 THEN
select_stmt := 'SELECT ''dummy'' FROM dual';
OPEN csrresultset_inout FOR select_stmt;
END IF;
END IF;
-- If intdocount_in is 2, UI just wants to get the totalrows to give
-- the warning to users if the result set exceeds the limit set by
-- UI. When ntdocount_in is 2, the following block won't be executed.
IF intdocount_in IN (0,1) THEN
-- Construct the select query by calling XL_SPG_GetPagingSql.
-- This is the main query for this stored procedure
strOrderByClause := ' usr.usr_login';
--strOrderByClause := ' req.req_key';
IF strsortorder_in = 'DESC' THEN
intSortDirection_in := 0;
ELSE
intSortDirection_in := 1;
END IF;
XL_SPG_GetPagingSql(strColumnList,
strFromClause,
whereclause,
strOrderByClause,
intSortDirection_in,
intStartRow_in,
intPageSize_in,
select_stmt
OPEN csrresultset_inout FOR select_stmt;
END IF;
-- Exception Handling
EXCEPTION
WHEN Str_row THEN
RAISE_APPLICATION_ERROR(sqlcode,
'Start Row/Page Size cannot be NULL OR less than or equal to zero ');
WHEN Do_cnt THEN
RAISE_APPLICATION_ERROR(sqlcode,
'Do Count must be 0, 1 or 2. ');
WHEN no_logged_in_user THEN
RAISE_APPLICATION_ERROR(sqlcode,
'Logged-in User Key cannot be NULL OR less than or equal to zero ');
END;
end XL_SP_ROGUEUSERS;
But Am getting the following error message, I couldn't figure wat it is.Can anyone help me:-
PLS-00103: Encountered the symbol "NO" when expecting one of the following: * & = - + ; < / > at in is mod remainder not rem return returning <an exponent (**)> <> or != or ~= >= <= <> and or like LIKE2_ LIKE4_ LIKEC_ between into using || bulk member SUBMULTISET_Please use tags when posting code. Also please format the code so that blocks line up vertically - often that makes syntax errors like missing END IFs etc much easier to spot.
Maybe you are looking for
-
Feature Requests for next version of Pr
I've submitted this list. If you agree, please join me. Copy and paste into the Feature Request page if you like. Add your own requests. AUDIO: Ability to save track or clip based audio effect user presets. Option-drag to copy an audio effect from
-
Sun Directory Server Password Policy Problems
Hi, I am using Sun Directory Server and Sun AM (2005Q1). We are using SUN DS to configure the password policy to expire user passwords after 30 days. Also, the warning has been set to "one day before expiry". However, when the warning IS displayed to
-
Anyway to Detect all Installs of Oracle Throughout a Domain ?
hi experts, I have been tasked with presenting a list of all the versions of Oracle that are installed on any of our servers. I know we have some Oracle 7.9 databases and some Oracle 10g databases and probably others. Is there a command or a script y
-
"iTunes music" folder inside "iTunes"
in iTunes preferences i have /Users/me/Music/iTunes for my iTunes Media folder location inside this folder i find a folder called "iTunes Music" that contains: duplications from the "iTunes" folder (in the higher level), songs/albums which are exclu
-
Trying to sign into iTunes on a new computer.
Trying to sign into iTunes on a new computer. I need to verify by putting in my visa card security code but it wont let me.