Deadlock error in trigger

I created the following trigger and my requirement is updating the table with status column y, if the status column null values are less
than particular number have to insert few records into the same table...here is the code..
CREATE OR REPLACE TRIGGER WMOS_TEMP.insert_rec
after UPDATE
ON RSORT_TEMP
REFERENCING NEW AS New OLD AS Old
for each row
WHEN (
new.status = 'Y'
DECLARE
null_count pls_integer;
pragma autonomous_transaction;
begin
select count(*) into null_count from rsort_temp where status is null;
dbms_output.put_line ('null_count'||null_count);
if(null_count < 2) then
INSERT INTO rsort_temp
SELECT 1,ddm.dock_door_brcd, ah.SHPMT_NBR, ch.case_nbr,NULL
FROM case ch, asn ah, master ddm
WHERE ch.ORIG_NBR = ah.SHPMT_NBR
AND ch.ORIG_NBR = ddm.curr_nbr
AND ah.stat_code >= 10
AND ah.stat_code <= 30
AND ch.stat_code = 0
AND SUBSTR (ddm.brcd, 1, 2) = 'DR' and rownum < 10 ;
commit;
end if;
END;
but I got the following error:
ORA-04091: table WMOS_TEMP.RECEIVEANDSORT_TEMP is mutating, trigger/function may not see it
ORA-06512: at "WMOS_TEMP.INSERT_REC", line 4
ORA-04088: error during execution of trigger 'WMOS_TEMP.INSERT_REC'
Can you tell me how to code so that my requirement got done.
Thanks,

Hi,
There's a lot wrong with this solution. You need to read about the mutating table error.
First, in a row-level trigger you cannot reference your own trigger table in a select, insert, update or delete, because a change is still in progress, there's no consistent picture of the data there.
Second, you can't commit transactions in a trigger, they're not an atomic part of a transaction.
The "pragma autonomous transaction" was not created to circumvent those issues, so you need to rethink your logic. You either have to put that code in a stored procedure, likely the ideal option, or you could
use the workaround with a package, and using statement level trigger with the row level to accomplish that logic (which Tom shows in his AskTom post below).
Read these texts please. There's some database fundamentals you need to grasp before you think of the best solution for this problem.
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:9579487119866
http://www.oracle.com/technology/oramag/oracle/08-sep/o58asktom.html

Similar Messages

  • Error-Code: ora-4020 Deadlock error, while updating a record

    Hello!
    Is it possible to get a deadlock error when two or more users try to update the same record simultaneously? And what would be the best solution to circumvent this?
    Thanks
    Your help is appreciated.

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by ( vidya):
    Hello Vidhya,
    Issue either Commit or Rollback without much delay once the statement(s) is/are executed.
    vmkrish
    [email protected]
    Is it possible to get a deadlock error when two or more users try to update the same record simultaneously? And what would be the best solution to circumvent this?
    Thanks
    Your help is appreciated.<HR></BLOCKQUOTE>
    null

  • Deadlock error on logical standby

    Hi All,
    I am get an issue where every thing is working fine on Db server but when it is getting replicated to Logical standby i am getting a deadlock error. Please find error logs below
    Fri May 20 21:00:56 2011
    ORA-00060: Deadlock detected. More info in file /u01/logicalstdby_home/product/admin/XXXXX/bdump/xxlog_p004_15175.trc.
    Fri May 20 21:00:56 2011
    8
    Errors in file /u01/logicalstdby_home/product/admin/XXXXX/bdump/xxlog_lsp0_2207.trc:
    ORA-12801: error signaled in parallel query server P004
    ORA-00060: deadlock detected while waiting for resource
    9
    ORA-12801: error signaled in parallel query server P004
    ORA-00060: deadlock detected while waiting for resource
    LOGSTDBY Analyzer process P003 pid=42 OS id=15173 stopped
    Please can anyone help in investigation.
    Thanks and Regrads,
    Amol

    Hi ,
    I have the logs from deadlock file.
    There are two queries in this dump. Does this mean that the two queries in the logs (which are actually same) are runing in parellel. Because this actually ran fine on the primary database.
    DEADLOCK DETECTED ( ORA-00060 )
    [Transaction Deadlock]
    The following deadlock is not an ORACLE error. It is a
    deadlock due to user error in the design of an application
    or from issuing incorrect ad-hoc SQL. The following
    information may aid in determining the deadlock:
    Deadlock graph:
    ---------Blocker(s)-------- ---------Waiter(s)---------
    Resource Name process session holds waits process session holds waits
    TX-01350024-00098ad3 44 804 X 46 797 S
    TX-012f0006-0008ac28 46 797 X 60 874 S
    TX-01340000-000a175c 60 874 X 44 804 S
    session 804: DID 0001-002C-0003E40C     session 797: DID 0001-002E-00002364
    session 797: DID 0001-002E-00002364     session 874: DID 0001-003C-0000019C
    session 874: DID 0001-003C-0000019C     session 804: DID 0001-002C-0003E40C
    Rows waited on:
    Session 797: obj - rowid = 00000000 - D/////AAaAAHqeAAAA
    (dictionary objn - 0, file - 26, block - 2008960, slot - 0)
    Session 874: obj - rowid = 00089976 - AAC5PjAAFAAAmj+AAA
    (dictionary objn - 563574, file - 5, block - 157950, slot - 0)
    Session 804: obj - rowid = 00089976 - AAC5PjAAFAAAmi3AAA
    (dictionary objn - 563574, file - 5, block - 157879, slot - 0)
    Information on the OTHER waiting sessions:
    Session 797:
    pid=46 serial=418 audsid=0 user: 0/SYS
    O/S info: user: oracle, term: UNKNOWN, ospid: 15180, machine: db5p
    program: oracle@db5p (P006)
    Current SQL Statement:
    update /*+ streams restrict_all_ref_cons */ "BEBSS"."SUBSCRIBER_POLICY_BROKER_EVENT" p set "ACTIVITY_TYPE"=decode(:1,'N',"ACTIVITY_TYPE",:2), "ATTRIBUTE_SET"=decode(:3,'N',"ATTRIBUTE_SET",:4), "CREATED_DATE"=decode(:5,'N',"CREATED_DATE",:6), "CUSTOMER_ID"=decode(:7,'N',"CUSTOMER_ID",:8), "FILE_NAME"=decode(:9,'N',"FILE_NAME",:10), "ID"=decode(:11,'N',"ID",:12), "LAST_MODIFIED_DATE"=decode(:13,'N',"LAST_MODIFIED_DATE",:14), "PORT_NUMBER"=decode(:15,'N',"PORT_NUMBER",:16), "PROCESSED_DATE"=decode(:17,'N',"PROCESSED_DATE",:18), "SERVICE_PACKAGE_ID"=decode(:19,'N',"SERVICE_PACKAGE_ID",:20), "STATUS"=decode(:21,'N',"STATUS",:22), "TRANSACTION_TYPE"=decode(:23,'N',"TRANSACTION_TYPE",:24) where (:25='N' or(decode(:26,'N','Y',decode(:27,"ACTIVITY_TYPE",'Y'))='Y' and decode(:28,'N','Y',decode(:29,"ATTRIBUTE_SET",'Y'))='Y' and decode(:30,'N','Y',decode(:31,"CREATED_DATE",'Y'))='Y' and decode(:32,'N','Y',decode(:33,"CUSTOMER_ID",'Y'))='Y' and decode(:34,'N','Y',decode(:35,"FILE_NAME",'Y'))='Y' and 1=1 and decode(:36,'N','Y',decode(:37,"LAST_MODIFIED_DATE",'Y'))='Y' and decode(:38,'N','Y',decode(:39,"PORT_NUMBER",'Y'))='Y' and decode(:40,'N','Y',decode(:41,"PROCESSED_DATE",'Y'))='Y' and decode(:42,'N','Y',decode(:43,"SERVICE_PACKAGE_ID",'Y'))='Y' and decode(:44,'N','Y',decode(:45,"STATUS",'Y'))='Y' and decode(:46,'N','Y',decode(:47,"TRANSACTION_TYPE",'Y'))='Y')) and(:48="ID")
    Session 874:
    pid=60 serial=20958 audsid=0 user: 0/SYS
    O/S info: user: oracle, term: UNKNOWN, ospid: 15182, machine: db5p
    program: oracle@db5p (P007)
    Current SQL Statement:
    update /*+ streams restrict_all_ref_cons */ "BEBSS"."SUBSCRIBER_POLICY_BROKER_EVENT" p set "ACTIVITY_TYPE"=decode(:1,'N',"ACTIVITY_TYPE",:2), "ATTRIBUTE_SET"=decode(:3,'N',"ATTRIBUTE_SET",:4), "CREATED_DATE"=decode(:5,'N',"CREATED_DATE",:6), "CUSTOMER_ID"=decode(:7,'N',"CUSTOMER_ID",:8), "FILE_NAME"=decode(:9,'N',"FILE_NAME",:10), "ID"=decode(:11,'N',"ID",:12), "LAST_MODIFIED_DATE"=decode(:13,'N',"LAST_MODIFIED_DATE",:14), "PORT_NUMBER"=decode(:15,'N',"PORT_NUMBER",:16), "PROCESSED_DATE"=decode(:17,'N',"PROCESSED_DATE",:18), "SERVICE_PACKAGE_ID"=decode(:19,'N',"SERVICE_PACKAGE_ID",:20), "STATUS"=decode(:21,'N',"STATUS",:22), "TRANSACTION_TYPE"=decode(:23,'N',"TRANSACTION_TYPE",:24) where (:25='N' or(decode(:26,'N','Y',decode(:27,"ACTIVITY_TYPE",'Y'))='Y' and decode(:28,'N','Y',decode(:29,"ATTRIBUTE_SET",'Y'))='Y' and decode(:30,'N','Y',decode(:31,"CREATED_DATE",'Y'))='Y' and decode(:32,'N','Y',decode(:33,"CUSTOMER_ID",'Y'))='Y' and decode(:34,'N','Y',decode(:35,"FILE_NAME",'Y'))='Y' and 1=1 and decode(:36,'N','Y',decode(:37,"LAST_MODIFIED_DATE",'Y'))='Y' and decode(:38,'N','Y',decode(:39,"PORT_NUMBER",'Y'))='Y' and decode(:40,'N','Y',decode(:41,"PROCESSED_DATE",'Y'))='Y' and decode(:42,'N','Y',decode(:43,"SERVICE_PACKAGE_ID",'Y'))='Y' and decode(:44,'N','Y',decode(:45,"STATUS",'Y'))='Y' and decode(:46,'N','Y',decode(:47,"TRANSACTION_TYPE",'Y'))='Y')) and(:48="ID")
    End of information on OTHER waiting sessions.
    Current SQL statement for this session:
    update /*+ streams restrict_all_ref_cons */ "BEBSS"."SUBSCRIBER_POLICY_BROKER_EVENT" p set "ACTIVITY_TYPE"=decode(:1,'N',"ACTIVITY_TYPE",:2), "ATTRIBUTE_SET"=decode(:3,'N',"ATTRIBUTE_SET",:4), "CREATED_DATE"=decode(:5,'N',"CREATED_DATE",:6), "CUSTOMER_ID"=decode(:7,'N',"CUSTOMER_ID",:8), "FILE_NAME"=decode(:9,'N',"FILE_NAME",:10), "ID"=decode(:11,'N',"ID",:12), "LAST_MODIFIED_DATE"=decode(:13,'N',"LAST_MODIFIED_DATE",:14), "PORT_NUMBER"=decode(:15,'N',"PORT_NUMBER",:16), "PROCESSED_DATE"=decode(:17,'N',"PROCESSED_DATE",:18), "SERVICE_PACKAGE_ID"=decode(:19,'N',"SERVICE_PACKAGE_ID",:20), "STATUS"=decode(:21,'N',"STATUS",:22), "TRANSACTION_TYPE"=decode(:23,'N',"TRANSACTION_TYPE",:24) where (:25='N' or(decode(:26,'N','Y',decode(:27,"ACTIVITY_TYPE",'Y'))='Y' and decode(:28,'N','Y',decode(:29,"ATTRIBUTE_SET",'Y'))='Y' and decode(:30,'N','Y',decode(:31,"CREATED_DATE",'Y'))='Y' and decode(:32,'N','Y',decode(:33,"CUSTOMER_ID",'Y'))='Y' and decode(:34,'N','Y',decode(:35,"FILE_NAME",'Y'))='Y' and 1=1 and decode(:36,'N','Y',decode(:37,"LAST_MODIFIED_DATE",'Y'))='Y' and decode(:38,'N','Y',decode(:39,"PORT_NUMBER",'Y'))='Y' and decode(:40,'N','Y',decode(:41,"PROCESSED_DATE",'Y'))='Y' and decode(:42,'N','Y',decode(:43,"SERVICE_PACKAGE_ID",'Y'))='Y' and decode(:44,'N','Y',decode(:45,"STATUS",'Y'))='Y' and decode(:46,'N','Y',decode(:47,"TRANSACTION_TYPE",'Y'))='Y')) and(:48="ID")
    ===================================================
    PROCESS STATE
    Process global information:
    process: 0x29c53bcc8, call: 0x29567f358, xact: 0x299db2d90, curses: 0x29c811dd8, usrses: 0x29c811dd8
    SO: 0x29c53bcc8, type: 2, owner: (nil), flag: INIT/-/-/0x00
    (process) Oracle pid=44, calls cur/top: 0x29567f358/0x29567eb18, flag: (0) -
    int error: 0, call error: 0, sess error: 0, txn error 0
    (post info) last post received: 0 0 117
    last post received-location: kcbzww
    last process to post me: 29c53fc08 42 0
    last post sent: 0 0 117
    last post sent-location: kcbzww
    last process posted by me: 29c53c4b0 188 0
    (latch info) wait_event=0 bits=0
    Process Group: DEFAULT, pseudo proc: 0x29f601e88
    O/S info: user: oracle, term: UNKNOWN, ospid: 15175
    OSD pid info: Unix process pid: 15175, image: oracle@db5p (P004)
    Dump of memory from 0x000000029C500F08 to 0x000000029C501110
    29C500F00 00000002 00000000 [........]
    29C500F10 9C811DD8 00000002 00000004 0003129B [................]
    29C500F20 8F34B7A0 00000002 0000001E 0003115B [..4.........[...]
    29C500F30 9CA03A98 00000002 0000000B 000313A7 [.:..............]
    29C500F40 9EBD0510 00000002 0000003D 0003115B [........=...[...]
    29C500F50 9C803260 00000002 00000004 0003129B [`2..............]
    29C500F60 75E66848 00000001 0000001E 0003115B [Hh.u........[...]
    29C500F70 99507DB0 00000002 00000007 000313A7 [.}P.............]
    29C500F80 99507F70 00000002 00000007 000313A7 [p.P.............]
    29C500F90 995083D0 00000002 00000007 000313A7 [..P.............]
    29C500FA0 99508CA8 00000002 00000007 000313A7 [..P.............]
    29C500FB0 995093C0 00000002 00000007 000313A7 [..P.............]
    29C500FC0 99509AC0 00000002 00000007 000313A7 [..P.............]
    29C500FD0 9950AC58 00000002 00000007 000313A7 [X.P.............]
    29C500FE0 9950B290 00000002 00000007 000313A7 [..P.............]
    29C500FF0 9950D6A0 00000002 00000007 000313A7 [..P.............]
    29C501000 994FDAB0 00000002 00000007 000313A7 [..O.............]
    29C501010 99510640 00000002 00000007 000313A7 [@.Q.............]
    29C501020 99510B80 00000002 00000007 000313A7 [..Q.............]
    29C501030 99510FE0 00000002 00000007 000313A7 [..Q.............]
    29C501040 99511298 00000002 00000007 000313A7 [..Q.............]
    29C501050 99511998 00000002 00000007 000313A7 [..Q.............]
    29C501060 99511A78 00000002 00000007 000313A7 [x.Q.............]
    29C501070 99511B58 00000002 00000007 000313A7 [X.Q.............]
    29C501080 99512350 00000002 00000007 000313A7 [P#Q.............]
    29C501090 99513248 00000002 00000007 000313A7 [H2Q.............]
    29C5010A0 99513408 00000002 00000007 000313A7 [.4Q.............]
    29C5010B0 99513788 00000002 00000007 000313A7 [.7Q.............]
    29C5010C0 9CA04DE8 00000002 0000000B 000313A7 [.M..............]
    29C5010D0 995144C0 00000002 00000007 000313A7 [.DQ.............]
    29C5010E0 99515038 00000002 00000007 000313A7 [8PQ.............]
    29C5010F0 995152D8 00000002 00000007 000313A7 [.RQ.............]
    29C501100 995159F0 00000002 00000007 000313A7 [.YQ.............]
    Thanks,
    Amol

  • Deadlock error in forms

    Hi,
    I have got an assignment to find out reasons for deadlock error in two forms. Client doesnot have any records
    like error number,message what soever. Please tell me how to trobleshoot it, what are things which I should check in forms,procedures etc.
    Thanks in advance.
    Sandy

    Can you reproduce the error? If not, it might be complicated.
    A deadlock occurs, in general, if two programs access two ressources in different order, and then two users run the two programs with the same database objects. The following is a short overview, leaving out some details.
    Lets say, program (or form) A updates table T1 for a specific object O, and then update table T2 for a specific object O.
    And program (or form) B first updates table T2 for a specific object O and then update table T1 for a specific object O.
    When two users run the two programs for the same object O, the following happens (assuming the appropiate "timing"):
    User U1 starts working with program A and updates table T1 for the object O, the appropiate reocrd in T1 now is locked.
    User U2 starts working with program B and updates table T2 for the same object O, the appropiate record in T2 now is locked.
    Now user U1 continues with program A and tries to update T2. This will not work, for T2 is already locked by user U2, so the session will wait.
    Now user U2 continues with program B and tries to update T1. This will not work, for T1 is already locked by user U1, so the session will wait.
    Now U1 waits for U2 and U2 waits for U1, this is called a deadlock. The database is able to detect this situation and raises an error.
    So, to find that situation:
    Look for manual UPDATE's or DELETE's inside the forms
    Look for transactiosn where some tables are involved in different order.
    Hope this helps.

  • Could we get a deadlock error on COMMIT (END TRANSACTION) in BDB-SQL

    According to the DB_TXN->commit documentation at:
    http://download.oracle.com/docs/cd/E17076_02/html/api_reference/C/txncommit.html
    "After DB_TXN->commit() has been called, regardless of its return, the DB_TXN handle may not be accessed again.
    If DB_TXN->commit() encounters an error, the transaction and all child transactions of the transaction are aborted."
    Since BDB-SQL uses the BDB engine, should the code handle such errors in BDB-SQL?
    Another point to keep in mind is that, post BDB-SQL version 5.1 upon receiving a potential deadlock error all the previous operations(child transactions) in the same transaction are still valid and can be committed.
    It would be great if someone can throw some light on this.
    Edited by: user10942853 on Jul 28, 2011 9:31 AM

    user10942853 wrote:
    LaurenFoutz wrote:
    I do not think commit can experience a deadlock error since it does not obtain any new locks, and it could not have been in a blocked state if you are able to call commit. Either way, after calling commit on a transaction in SQL the transaction is done, even if an error is returned. At that point if an error is returned the transaction (and all the work its children have done) is either aborted under the covers, or the database has been corrupted, and all future calls to it will return a corruption error that will require restarting the database to restore it (and the restoration will roll back any work done by the transaction since it did not complete cleanly).
    Hope that answers your question.
    Lauren FoutzLauren, thanks for the reply. From your reply, though there is little possibility that we can get an error on commit looks like we should be prepared to handle such errors in BDB-SQL. We have had instances where we experienced an error on commit while using native BDB (without SQL API) and wanted to confirm the same.You are correct. Error when committing are rare in both the SQL and native API, but they can happen and you should deal with them when they do.
    Lauren Foutz

  • Event Queue Deadlock Error

    LabVIEW 7.1, PDA Module for Palm OS (long-time LV programmer, new to PDA module)
    I am writing an app that displays a main screen of choices via Boolean button controls.  An Event structure is used to detect ValueChange in the Booleans.  When a button is clicked, a sub-vi is called that opens the sub-vi's front panel that has data display and a couple of buttons that are also processed by an event structure.  I got a "event queue deadlocked" error message when testing.  Does this application structure violate the "single event structure in a loop" rule, even though one queue is in a sub-vi?  Must I use a state machine or some other architecture to make this work?
    Thanks,
    BevP

    A lot of time has passed but now I find the same problem and I have the solution.
    If you have an event structure you MUST show the control and indicators involved in the cases in the front panel and in the monitor of your PDA/Touchscreen device, because oterwise the event queue deadlocked error appears.
    It makes sense becasuse if you do not show them; you will never be able to call events and the aplication is going to stuck. 

  • Deadlock error

    Hi , iam geeting a dead log error from an autonomous trigger.
    But in log file it show the same session nos'
    DEADLOCK DETECTED ( ORA-00060 )
    [Transaction Deadlock]
    The following deadlock is not an ORACLE error. It is a
    deadlock due to user error in the design of an application
    or from issuing incorrect ad-hoc SQL. The following
    information may aid in determining the deadlock:
    Deadlock graph:
                           ---------Blocker(s)--------  ---------Waiter(s)---------
    Resource Name          process session holds waits  process session holds waits
    TX-00010003-00000459        16     188     X             16     188           X
    session 188: DID 0001-0010-000021B4     session 188: DID 0001-0010-000021B4
    Rows waited on:
    Session 188: obj - rowid = 00002F8A - AAAC+KAAEAAACzcAAA
      (dictionary objn - 12170, file - 4, block - 11484, slot - 0)
    Information on the OTHER waiting sessions:
    End of information on OTHER waiting sessions.
    Current SQL statement for this session:
    UPDATE SUMMARY SET NAME = :B1 WHERE Mint_NAME = TO_CHAR(:B2 )
    ----- PL/SQL Call Stack -----
      object      line  object
      handle    number  name
    1B5C1E9C       109  BF_AU_IP_TEST
    1F957020      8352  package body  MINT
    1B719024        19  package body ALOADER
    1B7615E0         1  anonymous block
    ===================================================THIS IS MY AUTONOMOUS TRIGGER -BF_AU_IP_TEST
    this trigger has the following update staetment
    UPDATE SUMMARY SET NAME = :B1 WHERE Mint_NAME = TO_CHAR(:B2 )
    Edited by: user8792751 on Aug 19, 2010 2:59 AM

    Deadlock graph:
                           ---------Blocker(s)--------  ---------Waiter(s)---------
    Resource Name          process session holds waits  process session holds waits
    TX-00010003-00000459        16     188     X             16     188           Xyou have a TX (transaction) enqueue with exclusive mode (X) being held and exclusive mode(X) being waited on
    Which means that two sessions are doing concurrent DML on the same target.
    you have the sql statement involved in the deadlock and you have the row waited on
    Rows waited on:
    Session 188: obj - rowid = 00002F8A - AAAC+KAAEAAACzcAAAremember that an autonomous transaction when called represents a new session and then don't be surprised to observe deadlock in this situation.
    But, please, let me know why you are
    (a) using an autonomous transaction
    (b) and using an autonomous transaction in trigger
    I may help you to find another way to do your requirement
    Regards
    Mohamed Houri

  • HSDIO conditionally fetch hardware compare sample errors (script trigger to flag whether or not to wait for software trigger)

    I am moderately new to Labview and definitely new to the HSDIO platform, so my apologies if this is either impossible or silly!
    I am working on a system that consists of multiple PXI-6548 modules that are synchronized using T-CLK and I am using hardware compare.  The issue I have is that I need to be able to capture ALL the failing sample error locations from the hardware compare fetch VI... By ALL I mean potentially many, many more fails than the 4094 sample error depth present on the modules.
    My strategy has been to break up a large waveform into several subsets that are no larger than 4094 samples (to guarantee that I can't overflow the error FIFO) and then fetch the errors for each block.  After the fetch is complete I send a software reference trigger that is subsequently exported to a scriptTrigger that tells the hardware it is OK to proceed (I do this because my fetch routine is in a while loop and Labview says that the "repeated capbility has not yet been defined" if I try to use a software script trigger in a loop).
    This works fine, but it is also conceivable that I could have 0 errors in 4094 samples.  In such a case what I would like to do is to skip the fetching of the hardware compare errors (since there aren't any) and immediately begin the generation of the next block of the waveform.  That is, skip the time where I have to wait for a software trigger.
    I tried to do this by exporting the sample error event to a PFI and looping that PFI back in to generate a script trigger.  What I thought would happen was that the script trigger would get asserted (and stay asserted) if there was ever a sample error in a block, then I could clear the script trigger in my script.  However, in debug I ended up exporting this script trigger back out again and saw that it was only lasting for a few hundred nanoseconds (in a case where there was only 1 injected sample error)... The sample error event shows up as a 1-sample wide pulse.
    So, my question is this:  is there a way to set a flag to indicate that at least one sample error occurred in a given block  that will persist until I clear it in my script?  What I want to do is below...
    generate wfmA subset (0, 4094)
    if scriptTrigger1
      clear scriptTrigger1
      wait until scriptTrigger0
    end 
    clear scriptTrigger0
    generate wfmA subset (4094, 4094)
    I want scriptTrigger1 to be asserted only if there was a sample error in any block of 4094 and it needs to stay asserted until it is cleared in the script.  scriptTrigger0 is the software trigger that will be sent only if a fetch is performed.  Again, the goal being that if there were no sample errors in a block, the waiting for scriptTrigger0 will not occur.
    I am probably going about it all wrong (obviously since it doesn't work), so any help would be much appreciated!

    Please disregard most of my previous post... after some more debug work today I have been able to achieve the desired effect at slower frequencies.  I did straighten out my script too:
    generate wfmA
    if scriptTrigger1
      clear scriptTrigger0
      wait until scriptTrigger0
    end if
    generate wfmA
    scriptTrigger1 = sample error event flag
    scriptTrigger0 = software trigger (finished fetching error backlog in SW)
    However, I am still having a related issue.
    I am exporting the Sample Error Event to a PFI line, looping that back in on another PFI line, and having the incoming version of the Sample Error Event generate a script trigger.  My stimulus has a single injected sample error for debug. For additional debug I am exporting the script trigger to yet another PFI; I have the sample error event PFI and the script trigger PFI hooked up to a scope.
    If I run the sample clock rate less than ~133MHz everything works... I can see the sample error event pulse high for one clock period and the script trigger stays around until it is consumed by my script's if statement.
    Once I go faster than that I am seeing that the script trigger catches the sample error event occasionally.  The faster I go, the less often it is caught.  If I widen out the error to be 2 samples wide then it will work every time even at 200MHz.
    I have tried PFI0-3 and the PXI lines as the output terminal for the sample error event and they all have the same result (this implies the load from the scope isn't the cause).
    I don't know what else to try?  I can't over sample my waveform because I need to run a true 200MHz. I don't see anything that would give me any other control over the sample error event in terms of its pulsewidth or how to export it directly to a script trigger instead of how I'm doing it.
    Any other ideas?

  • How can i creat a trigger    error  invalid trigger specification

    i have a stored procedure which i want it to be triggered when an insertion is done on table A
    and that stored procedure accepts values from the insertion performed in table A
    and inserts into Table B by either updating the table or insertion into Table B
    how can i achieve this
    OK fine i have a table called Table A
    i want a trigger that can accept values such as
    create or replace trigger UpdateMyDoc  after insert on  Table A
    for each row
    accoutntno varchar2,
    ID varchar2
    As
    cnt number;
    Begin
    update Table B value (accoutntno ,ID ); commit;
    end ;
    is the above possible if it is then i get this  [1]: (Error): ORA-04079: invalid trigger specification
    any help
    Edited by: kama021 on Aug 13, 2009 2:24 AM

    Stop right there, Kama.
    update Table B value (accoutntno ,ID ); commit;Do not go any further on triggers, until you at least know how to write an UPDATE
    Or is it INSERT
    Once you have that in place, carry on by reading a bit about Transactions
    Regards
    Peter

  • Error in trigger

    Hi,
    I am stuck with the error PLS-00103.
    Actually what I want to do is, I have a table user_info which holds the details about the users like passwords.
    Each time a user updates a password in the table, the new password should go into the varrying array old_passwords, which is an attribute in the table. If the number of passwords are equal to the size(i.e 10) of the array then,
    the new password which is being updated should be checked whether it is already there in the last 10 passwords,
    if it is there then I have to raise an exception, otherwise I have to trim the last password from the array and add the new password to the first position of the array.
    And for inserting the passwords I have a procedure called add_password which takes a varying object and the new password as parameters. I have written the code in order to avoid the mutating table error.
    I am showing all that I have done, I wil be very thankful, if anyone can suggest me a way to solve the problem.
    -- Table user_info
    create table User_Info(Name varchar2(20),
    Passwd varchar2(10),
    E_Mail varchar2(30) constraint email_pk primary key deferrable initially immediate,
    Rank varchar2(20),
    Country varchar2(30) constraint user_fk references country, Passwd_Change_Date date,
    Last_Login date,
    Old_Passwords Old_Passwds_Ty,
    constraint uname_uq unique(name));
    -- package to avoid mutating table error
    create or replace package new_pas as
    type pwd_ty is table of user_info%rowtype index by binary_integer;
    upwd_table pwd_ty;
    end new_pas;
    --after row level trigger to store new values
    create or replace trigger b_trig
    after update of passwd on user_info
    for each row
    begin new_pas.upwd_table(new_pas.upwd_table.count+1).passwd:=:new.passwd; new_pas.upwd_table(new_pas.upwd_table.count+1).name:=:old.name;
    end b_trig;
    -- after statement level trigger
    create or replace trigger trig_pass after update of passwd on user_info
    begin
    declare old_pass old_passwds_ty;
    begin select old_passwords into old_pass from user_info where name=new_pas.upwd_table(new_pas.upwd_table.count+1).name;
    if old_pass is null or old_pass.count<old_pass.limit then
    add_password(old_passwds_ty('some'),new_pas.upwd_table(new_pas.upwd_table.count+1).passwd);
    elsif old_pass.count=old_pass.limit then
    for i in 1 .. old_pass.count loop
    if old_pass(i)=new_pas.upwd_table(new_pas.upwd_table.count+1).passwd then raise exceptions_package.Invalid_password;
    end if;
    end loop;
    add_password(old_passwds_ty('some'),new_pas.upwd_table(new_pas.upwd_table.count+1).passwd);
    new_pas.upwd_table.delete;
    end if;
    end trig_pass;
    -- The error while compiling this trigger is:
    37/0 PLS-00103: Encountered the symbol "end-of-file" when expecting one of the follow ing: begin case declare end exception exit for goto if loop mod null pragma raise return select update while with ><an identifier> << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe
    -- The body of add_password is:
    create or replace procedure Add_password(user_pwd old_passwds_ty,pwd user_info.passwd%type) is
    new_pass old_passwds_ty;
    u_pwd old_passwds_ty;
    begin
    u_pwd:=user_pwd;
    for rec in (select old_passwords from user_info) loop
    u_pwd:=rec.old_passwords;
    if u_pwd is null then
    new_pass:=old_passwds_ty(pwd);
    elsif u_pwd.count=u_pwd.limit then
    new_pass:=old_passwds_ty(pwd);
    u_pwd.trim;
    for i in 1 .. u_pwd.count loop
    new_pass(i+1):=u_pwd(i);
    end loop;
    exit;
    end if;
    end loop;
    update user_info set old_passwords=new_pass; end add_password;
    Thanks for reading, I will be very thankful, If I can get a solution

    -- after statement level trigger
    create or replace trigger trig_pass after update of passwd on user_info
    begin
    declare old_pass old_passwds_ty;
    begin select old_passwords into old_pass from user_info where name=new_pas.upwd_table(new_pas.upwd_table.count+1).name;
    if old_pass is null or old_pass.count<old_pass.limit then
    add_password(old_passwds_ty('some'),new_pas.upwd_table(new_pas.upwd_table.count+1).passwd);
    elsif old_pass.count=old_pass.limit then
    for i in 1 .. old_pass.count loop
    if old_pass(i)=new_pas.upwd_table(new_pas.upwd_table.count+1).passwd then raise exceptions_package.Invalid_password;
    end if;
    end loop;
    add_password(old_passwds_ty('some'),new_pas.upwd_table(new_pas.upwd_table.count+1).passwd);
    new_pas.upwd_table.delete;
    end if;
    end;
    end trig_pass;
    Need one more end;
    /

  • Error in Trigger ( PL/SQL: ORA-01744: inappropriate INTO)

    Hi ,
    I've written the trigger in the following format.. As the original trigger is around 700 lines, so just format is written here.. please co-operate..
    CREATE OR REPLACE TRIGGER --
    AFTER UPDATE OF COL1
    ON TAB1
    REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    WHEN (NOT(OLD.COL1 IS NULL AND NEW.COL1=0))
    DECLARE
    rowToins PAK1.fdList;
    i number;
    BEGIN
    IF :NEW.COL2='V' THEN
    INSERT INTO DEST(
      D_AT)
    SELECT * FROM ( SELECT --
       PAK2.FUN1('AD',TAB10.ID) AS D_AT
    FROM ---
    WHERE --- )
       WHERE D_AT IS NOT NULL;
    ELSEIF :NEW.COL2 ='H' THEN
    SELECT * FROM ( SELECT --
       PAK2.FUN1('AD',TAB9.ID) AS D_AT
    BULK COLLECT INTO rowToins
    FROM ---
    WHERE --- )
       WHERE D_AT IS NOT NULL;
    i:=rowToins.FIRST;
    WHILE i IS NOT NULL LOOP
    --insert row 1
      PAK1.fun2(rowToins(i).<col>,
    i:=rowToins.NEXT(i);
    END LOOP;
    END IF;
    END;
    /The above code is giving the error..
    PL/SQL: ORA-01744: inappropriate INTOSo how can i correct the code...
    thanks

    The line no..are
    159/3 PL/SQL: SQL Statement ignored
    213/16 PL/SQL: ORA-01744: inappropriate INTO
    159 --> the first where condition in the example code
    213 --> the select list column in the second if condition in example code
    If i remove the
    select * from (
    PAK2.FUN1('AD',TAB9.ID) AS D_AT
    WHERE D_AT IS NOT NULL;Then the trigger is created with no issues....
    please let me know if i'm not clear
    Edited by: josh1612 on Apr 27, 2009 3:42 AM

  • Data Committed instead of Rollback after Deadlock Error in SQL Server 2008 R2 (SP2)

    We're having a strange issue which is occurring only with one Customer having SQL Server 2008 R2 (SP2).
    Basically we have multiple threads uploading data and when an error occurs (like deadlock or any other error). The deadlock victim (process/transaction) is rolledback (from .NET). However the rollback command is not reaching SQL Server as it doesn't show
    in the trace (through SQL Profiler).
    To make things worse, not only the transaction is not being rolled back but the INSERTs executed before the error are being somehow committed, leaving the database in an inconsistent state.
    This is only produced in one environment.
    Any idea what the issue could be?

    All statements are executed with in a Transaction. Under the same scenario this code works perfectly fine for 1000s of customers. Only one customer has this issue.
    You need to capture profiler to check transaction scope.
    Balmukund Lakhani
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    | Facebook
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • Error On trigger while adding a date

    This is my trigger i want to add 15 dates to issue date,while running a trigger its showing error,
    try to solve that trigger
    create or replace
    TRIGGER ISSUE_BOOK_TRI
    BEFORE
    INSERT ON issue_book FOR EACH ROW
    DECLARE
    CURSOR a IS
    SELECT join_date FROM member_book;
    p_join_date DATE;
    BEGIN
    OPEN a;
    FETCH a INTO p_join_date;
    IF p_join_date> :new.issue_date THEN
    RAISE_APPLICATION_ERROR (-20322,'You may Issue book only after joining');
    elsif
    :new.return_date := :new.issue_date+15;
    end if;
    CLOSE a;
    END;
    Error(15,22): PLS-00103: Encountered the symbol "=" when expecting one of the following: . ( * @ % & = - + < / > at in is mod remainder not rem then <an exponent (**)> <> or != or ~= >= <= <> and or like like2 like4 likec between || indicator multiset member submultiset
    Error(16,5): PLS-00103: Encountered the symbol "END" when expecting one of the following: begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current cursor delete exists prior

    /* Formatted on 2012/04/25 14:22 (Formatter Plus v4.8.8) */
    CREATE OR REPLACE TRIGGER issue_book_tri
      BEFORE INSERT
      ON issue_book
      FOR EACH ROW
    DECLARE
      CURSOR a
      IS
        SELECT join_date
          FROM member_book;
      p_join_date   DATE;
    BEGIN
      OPEN a;
      FETCH a
       INTO p_join_date;
      IF p_join_date > :NEW.issue_date
      THEN
        raise_application_error (-20322, 'You may Issue book only after joining');
      ELSIF 1 = 1 -- uuuuuu miss the condition here
      THEN
        :NEW.return_date := :NEW.issue_date + 15;
      END IF;
      CLOSE a;
    END;

  • Deadlocked error message when running crystal report

    Hi All,
    I need a bit of guidance as to the following problem.
    Seems there is a lock being created in SQL when running some crystal reports.
    When trying to run a report the following message is displayed:
    Database connection Error L 'ADO Error Code: 0x
    Source: Microsoft SQL Native Client
    Description: Transaction (Process ID 302) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
    SQL State: 40001
    Native Error: [Database Vendor Code: 1205 ]'
    The error is happening intermittently when refreshing the report. It does not seem to happen when no users are using the system.
    Is there any way to stop this from happening? Or is this some kind of limitation with crystal and how it accesses the database?
    Many Thanks,
    Matt

    Hi Matt
    I have had this problem with long running queries as well.  I ended up doing the main part of the query in a view using WITH (NOLOCK) for each table and then reporting on the view.
    This had extra benefits of making the report much simpler and often making the query more efficient and easier to test as well.
    Rob

  • When does Oracle throw the ORA-00060 , Deadlock error

    Hi,
    To test the "ORA-00060: Deadlock detected" we tried the below steps on scott schema.
    First session -
    update emp set sal=9999 where name='JACK';
    Second session -
    update emp set sal=5555 where name='JACK';
    We used the below query to find out which SID is locking the other;
    select l1.sid, ' IS BLOCKING ', l2.sid from v$lock l1, v$lock l2 where l1.block =1 and l2.request > 0 and l1.id1=l2.id1 and l1.id2=l2.id2;
    -- We got the SID's
    But in the alert log we are still not able to see the ORA-00060 error.
    Why is this ? In which scenario do we see the ORA-00060 error in alert log ?
    Please guide.
    Thanks.

    What you describe is just a blocking lock, not a deadlock.
    The first session can simply do commit and the second session can then continue.
    In a deadlock situation, nobody can commit if the system does not resolve the problem by rolling back one of the transactions:
    session1: lock row 1
    session 2: lock row 2
    session 1: try lock row 2 <- wait on session 2
    session 2: try lock row 1 <- wait on session 1
    both wait, enter ORA-600
    Kind regards
    Uwe Hesse
    http://uhesse.wordpress.com

Maybe you are looking for