Trigger error

I have create this trigger:

CREATE OR REPLACE TRIGGER old_date

BEFORE coupons INSERT, DELETE or UPDATE ON

FOR EACH LINE

BEGIN

Remove COUPON

WHERE correspondents < sysdate;

END;

so, I want to insert a new row in the table "coupons":

INSERT IN COUPONS (KUP_ID, UZS_ID, KLUBO_ID, KAINA, KREIPINYS, PALINKEJIMAS, expiration_date )

VALUES (18, 1, 1, 50, "Trigeri", 'Gero trigerio!', ' 2016-01-01');

and I get this...

Error starting 1 001 from command line:

INSERT COUPONS (KUP_ID, UZS_ID, KLUBO_ID, KAINA, KREIPINYS, PALINKEJIMAS, CORRESPONDENTS)

VALUES (18, 1, 1, 50, "Trigeri", 'Gero trigerio!', '' 2016-01-01)

Error report:

SQL error: ORA-04091: ANONYMOUS array. Vouchers is changing, function of triggering/can not see

ORA-06512: at "ANONYMOUS. OLD_DATE', line 2

ORA-04088: error during execution of trigger ' ANONYMOUS. OLD_DATE'

ORA-06512: at "ANONYMOUS. OLD_DATE', line 2

ORA-04088: error during execution of trigger ' ANONYMOUS. OLD_DATE'

04091 00000 - "table %s.%s is changing, function of triggering/can not see.

* Cause: A trigger (or plsql user-defined function that is referenced in)

This statement) attempted to watch (or modify) a table that has been

in the Middle being modified by the statement that shot.

* Action: Rewrite the trigger (or function) so it does not read this table.

The transfer of error, do not try to update at the same table for a trigger on which it is defined.

But if you really want to do this, try to create an immediate part time job of a trigger as

CREATE OR REPLACE TRIGGER old_date

BEFORE coupons INSERT, DELETE or UPDATE ON

FOR EACH LINE

BEGIN

dbms_job. Submit

(

work-online l_jobid,

What => ' remove COUPONS WHERE correspondents<>

next_date-online sysdate,

interval-online null

);

END;

Tags: Database

Similar Questions

  • FRM-40735: trigger ERROR raised unhandled exception ORA-06508

    I am having this error when executing my form this error before the page load screen I have not een know what trigger causes error

    FRM-40735: trigger ERROR raised unhandled exception ORA-06508'm in oracle 11 g 2 of the form how to find on which trigger causes error

    Hello

    Below is the cause of the error and for more information, see the link below.

    Question: An attempt was made to call a stored program that cannot be found.

    ORA-06508: PL/SQL: not found unit of programs called tips

    Oracle/PLSQL: ORA-06508

  • DAQmx Trigger: Error 2200077

    Hello

    I am trying to create a program to trigger a hammer signal, using a USB-6211 card and 4 analog inputs (via 1 DAQmx create channel HAVE voltage to the hammer and 3 others at the exit of the accelerometer). Having as a basis for some examples of LabView as "Acq Cont & voltage chart ' and 'Impact Test (DAQmx) [.vi SVXMPL_Impact Test (DAQmx)]', I built my program, but it does not work.

    If I don't put the relaxation and the task to start, my programme without any problem (in this case I use 4 DAQmx create channel HAVE tension, a DAQ Timing, linked to the DAQmx Read located on the loop). But when I add the trigger (start analog Edge) out of the loop, so that between the time the DAQmx Read, error-200077 apears and DAQmx. This same error apears too when I try to run the sample of "Cont Acq & voltage graph" (even if I change the sample rate and the number of samples, the error is still the same). The error-200431 apears when I try to launch the second example ("Impact Test (DAQmx) [SVXMPL_Impact Test (DAQmx) .vi]), but in this case probably the DAQ card is not suitable to run this program.

    When I add a task to start before the loop (where is located the DAQmx Read function) on my program without the shutter button, the error-200278 appears. And if I add the trigger and Start Task, just the apperas-200077 error function. However, the startup task is not bothering me as much as the trigger, because when I do not use the trigger on the example "Acq Cont & chart tension" and the task of beginning is always there, this program runs normally. In this case the problem is probably on my prgram and not on my data acquisition card.

    I just want to know if my card cannot run this trigger function (early analog Edge) or if there is something else, because it's strange how a relatively simple example can be run using my data acquisition card.

    Thank you

    Hi, FCB,.

    The USB-6211 can only be released digitally.

    The attached document allows you to see the specifications of your card:

    http://sine.NI.com/NIPs/CDs/view/p/lang/en/NID/203224

  • Reference with 6215 trigger: error 200452

    I am trying to create a trigger for reference to the analog inputs of sample. However, I get the following error:

    Error DAQmxBase-200452: specified property is not supported by the device or is not applicable to the task.

    And here is the code (which is actually from one of the sample codes)

    .

    Trip parameters
    Char [] triggerSource = ' / PFI0/Dev1;
    uInt32 triggerSlope = DAQmx_Val_RisingSlope;
    uInt32 triggerSamples = 100;
    .

    .

    .

    DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
    DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,));
    DAQmxErrChk (DAQmxBaseCfgSampClkTiming (taskHandle, clockSource, sampleRate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, samplesPerChan));

    DAQmxErrChk (DAQmxBaseCfgDigEdgeRefTrig (triggerSource, triggerSlope, taskHandle, triggerSamples));

    DAQmxErrChk (DAQmxBaseStartTask (taskHandle));
    DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByChannel,data,bufferSize,&pointsRead,));

    printf ("%d samples\n achievements", pointsRead);

    Print only the first 10 points
    for (i = 0; i< 10;="">
    printf ("data [%d] = %f\n", i, data [i] ");

    Reference trigger not taken the 6215? I m using the following:

    OpenSuse 11.2

    MX NI DAQ base 3.4.0

    LabVIEW 10.0

    I m basically just make use of the C API in my own program and do not use other software to configure the DAQ.

    Unfortunately, reference trigger is only supported in DAQmx Base 3.4 for the PCI, PCIe, PXI M Series (see the DAQmx Base 3.4 readme file).

    A possible solution would be to sample lines HAVE continuously and implement the reference trigger yourself in the software.

    Best regards

  • instead of trigger error

    Hi all

    I use

    Connected to Oracle Database 11g Express Edition Release 11.2.0.2.0

    I use the Oracle HR schema

    CREATE TABLE EMPLOYEES_COPY2 AS

    SELECT *.

    EMPLOYEES

    CREATE TABLE DEPARTMENTS_COPY2

    AS

    SELECT * FROM DEPARTMENTS

    CREATE TYPE employee_type AS OBJECT)

    VARCHAR2 (25) LAST_NAME,.

    E-MAIL VARCHAR2 (25).

    DATE OF HIRE_DAE,

    JOB_ID VARCHAR2 (10))

    CREATE THE EMPLOYEES_LIST TYPE

    AS THE employee_type TABLE

    CREATE VIEW DEPT_EMP_VIEW

    AS

    SELECT D.DEPARTMENT_ID,

    D.DEPARTMENT_NAME,

    CAST (MULTISET (SELECT SELECT,)

    E.EMAIL,

    E.HIRE_DATE,

    E.JOB_ID

    OF EMPLOYEES_COPY2 E

    WHERE E.DEPARTMENT_ID = D.DEPARTMENT_ID)

    AS EMPLOYEES_LIST) PGE

    OF DEPARTMENTS_COPY2 D

    SQL > CREATE OR REPLACE TRIGGER IO_BIFER_DEPT_EMP_VIEW

    2. INSTEAD OF

    3. INSERT ON DEPT_EMP_VIEW FOR EACH LINE

    4 BEGIN

    5 INSERT INTO DEPARTMENTS_COPY2 (DEPARTMENT_ID, DEPARTMENT_NAME)

    6 VALUES (: NEW.) DEPARTMENT_ID,: NEW. DEPARTMENT_NAME);

    7

    8. FOR i IN 1.. : NEW. PGE. COUNTY

    9 LOOP

    10 INSERT INTO EMPLOYEES_COPY2 (LAST_NAME, DEPARTMENT_ID, EMAIL, HIRE_DATE, JOB_ID)

    11 VALUES (: NEW.) (I) TIME. LAST_NAME,: NEW. (I) TIME. E-MAIL: NEW. (I) TIME. HIRE_DATE,: NEW. (I) TIME. JOB_ID,

    12: NEW. (I) TIME. DEPARTMENT_ID);

    13 END OF LOOP;

    14 END;

    15.

    WARNING: Trigger created with compilation errors

    SQL > show err

    Errors for the HR of the TRIGGER. IO_BIFER_DEPT_EMP_VIEW:

    LINE/COL ERROR

    -------- -------------------------------------------------

    8/71 PLS-00302: component 'HIRE_DATE' must be declared

    8/70 PL/SQL: ORA-00904: invalid identifier

    7/8 PL/SQL: statement ignored

    What is the error here, I'm not bale to understand.

    Help, please

    Thank you

    You have a typo in the definition of the type:

    CREATE TYPE employee_type AS OBJECT)

    VARCHAR2 (25) LAST_NAME,.

    E-MAIL VARCHAR2 (25).

    HIRE_DAE DATE,

    JOB_ID VARCHAR2 (10))

    Then correct the type definition or use: NEW. (I) TIME. HIRE_DAE in relaxation.

    SY.

  • Compilation of trigger error

    Hello

    I'm new with Oracle technology and I do not understand this error:

    Compilation failure, line 0 (18:19:09) line numbers associated with compilation errors are relative to the first BEGIN statement. This affects only the compilation of database triggers.

    PLS-00801: internal error [ph2csql_strdef_to_diana:bind] Compilation failed, line 12 (18:19:09) line numbers associated with compilation errors are relative to the first BEGIN statement. This affects only the compilation of database triggers.

    PL/SQL: ORA-06544: PL/SQL: internal error, arguments: [ph2csql_strdef_to_diana:bind] [] [] [], [], [], [], [] Compilation failed, line 10 (18:19:09) line numbers associated with compilation errors are relative to the first BEGIN statement. This affects only the compilation of database triggers.

    PL/SQL: SQL statement ignored


    This is the code:

    create or replace TRIGGER "BI_TBL_GAC_DEMANDES_AMEL"

    front Insert on 'TBL_GAC_DEMANDES_AMEL'

      for each row

    DECLARE

    v_users users% rowtype

    BEGIN

      if : NEW . "PK_ID_GAC_DEMANDE_AMEL" is null then

    -New PK

    Select 'TBL_GAC_DEMANDES_AMEL_SEQ'.nextval

          into : NEW . "PK_ID_GAC_DEMANDE_AMEL"

          from SYS . DUAL;

    -Find the recipient

        Select *

          into v_users

          from users

            where user_name = : v ('APP_USER') ;

    -Send msg responsible plan of action

    Insert into TBL_MESSAGES ( )

             DAT_MESSAGE ,

             TXT_TITRE ,

    FK_ID_EXPEDITEUR

    FK_ID_DESTINATAIRE

    FK_TXT_PROCEDURE

    FK_TXT_STATUT_MSG

             TXT_MESSAGE )

        values (

             SYSDATE ,

    ' New request improvement of,

            v_users . FK_ID_EMPLOYE,

            -- v_users . FK_ID_EMPLOYE,

    111,

            'GAC' ,

            'NEW' ,

    ' A new improvement request has been created and your intervention is requested '()

      end if ;

    END ;

    Thanks for help.

    > where user_name =: v ('APP_USER');

    incorrect syntax above

    What are you trying to do here?

    How can I ask a question in the forums?

    https://forums.Oracle.com/forums/thread.jspa?threadID=2174552#9360002

  • Trigger error - Table or view does not exist

    Hello

    I imported a dump of the database of Oracle 9i to Oracle 11 GR 2. Everything works fine, but I'm unable to compile the two triggers. Relaxation is provided in:

    {code}

    create or replace trigger tm_daily_activity_t_bf_update before update on tm_daily_activity_t start_t

    for each line

    Declare

    Time_now DATE;

    Varchar2 (40) Terminal.

    name VARCHAR2 (255);

    v_program VARCHAR2 (255);

    Start

    Time_now: = SYSDATE;

    Terminal: = USERENV ('TERMINAL');

    Select e-mail in the name of tm_employee_t where COID_ID0 =: OLD. EMPLOYEE_OBJ_ID0;

    Select the program from v_program v$ session;

    insert into tm_daily_activity_t_log values (: OLD.) START_T,: OLD. EMPLOYEE_OBJ_ID0,: OLD. ROWID,: OLD. CREATED_T, SYSDATE, TERMINAL, NAME, v_program);

    end;

    {/ code}

    {code}

    create or replace trigger tm_daily_activity_t_af_update after update on tm_daily_activity_t start_t

    for each line

    Declare

    v_program VARCHAR2 (255);

    Start

    Select the program in session v_program $ v where sid = (select distinct sid of sys.v$ mystat);

    If upper (v_program) = "TOAD. EXE' or upper (v_program) = ' SQLPLUSW. EXE' or upper (v_program) = ' SQLPLUS. EXE' or upper (v_program) = ' SQLPLUS @ "then

    raise_application_error (-20001, 'validation of completed trigger', true);

    end if;

    end;

    {/ code}

    Both triggers gave error ora-00942 table v$ session, but if I execute a select statement outside triggers it works fine.

    Any ideas what the permission is required?

    Privileges through roles do not apply to procedures, functions, or triggers. Try to connect SYS and giving a direct grant to select users for example

    Grant select on v_$ user session;

  • No data found Trigger error (before or after)

    Dear all,

    We have the trigger in the database, whenever we try to insert the record in WIP_OPERATIONS, NO DATA FOUND exception was thrown, when debugging we, we have found no problem. The first select statement is getting has not, even if there is the value entered for: NEW.wip_entity_id and when we execute the query separately in the database with the: NEW. WIP_ENTITY_ID, its getting the value. What could be the reason? We cannot use statement SELECT AFTER or BEFORE INSERT trigger? No idea why its NO_DATA_FOUND Exception throw?

    CREATE OR REPLACE TRIGGER sdm_brasil_wj_ops_iface_trg
    BEFORE YOU INSERT OR REMOVE
    ON WIP_OPERATIONS
    SEO
    AGAIN LIKE NEW
    OLD OLD
    FOR EACH LINE
    DECLARE
    ln_status NUMBER (10): = 0;
    ln_item_id Number (20);
    --
    lc_txn_type VARCHAR2 (1);
    v_interface_flag VARCHAR2 (1);
    v_err_msg VARCHAR2 (2000): = NULL;
    v_error VARCHAR2 (2000): = NULL;
    --
    lb_insert_iface BOOLEAN: = FALSE;
    --
    lr_discrete_job_ops wip_operations % ROWTYPE: = NULL;
    --
    BEGIN

    lr_discrete_job_ops.wip_entity_id: =: NEW.wip_entity_id;

    BEGIN

    INSERT INTO APPS. The VALUES of XX_TEMP (': NEW.wip_entity_id ' |: NEW.wip_entity_id);

    SELECT status_type
    IN ln_status
    OF wip_discrete_jobs
    WHERE wip_entity_id =: NEW.wip_entity_id;


    INSERT INTO APPS. The XX_TEMP VALUES ('ln_status' | ln_status);

    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    ln_status: = 0;
    v_error: = ' ERR001: NO DATA FOUND - primary item for WJ ID Id: ' | To_char (lr_discrete_job_ops.wip_entity_id): ' = > ' | SUBSTR (SQLERRM, 1, 500);
    dbg_pk.appmsg (1, vn | v_error);
    WHEN TOO_MANY_ROWS THEN
    ln_status: = 1;
    v_error: = ' ERR001: TOO Manu Rows: primary item for WJ ID Id: ' | To_char (lr_discrete_job_ops.wip_entity_id): ' = > ' | SUBSTR (SQLERRM, 1, 500);
    dbg_pk.appmsg (1, vn | v_error);
    WHILE OTHERS THEN
    ln_status: = 2;
    v_error: = ' ERR001: other - of the primary item for WJ ID Id: ' | To_char (lr_discrete_job_ops.wip_entity_id): ' = > ' | SUBSTR (SQLERRM, 1, 500);
    dbg_pk.appmsg (1, vn | v_error);
    END;

    932450 wrote:
    Hi Blushadow,

    Thanks for the reply, even I thought that the select statement is get executed before recording is committed to the database.

    How we can know, determine if the data enters the wip_discrete_jobs table?

    He didn't necessarily need to be committed, but it must have been inserted in the same session.
    The NO_DATA_FOUND error would seem to indicate that the trigger on the table wip_operations is put to fire until the data is inserted at wip_discrete_jobs. We have all your code, we are unable to identify the exact location of the error.

  • Application packed - Expertise Tracker Trigger error

    Good people good day:

    I recently installed a packaged application titled "Expertise Tracker" {Application Express 4.2.1.00.08}. It is an EXCELLENT application that I would use. However, one of the triggers seems to have an error. The trigger in question is:

    BIU_EBA_SME_CONTACTS and is composed as follows:

    create or replace
    biu_eba_sme_contacts relaxation
    before insert or update on EBA_SME_CONTACTS
    for each line
    declare
    OV varchar2 (4000);
    NV varchar2 (4000);
    Start
    If the insertion
    If: NEW.ID is null
    then select to_number (sys_guid (), 'FBI')
    in: NEW.ID
    Double;
    end if;
    : NEW. CREATED: = LOCALTIMESTAMP;
    : NEW. CREATED_BY: = nvl (v ('APP_USER'), USER);
    *: New.row_key: = eba_sme_fw.compress_int (eba_sme_rowkey_seq.nextval); *
    end if;

    If the insert or update can
    : NEW. SETTING A DAY: = LOCALTIMESTAMP;
    : NEW. UPDATED_BY: = nvl (v ('APP_USER'), USER);
    end if;
    -Photo postings
    -Size (limit of 200 KB)
    If the update and: NEW. PHOTO_NAME is not null and (dbms_lob.getlength(:NEW.) nvl (PHOTO_BLOB), 0) > 204800 then
    raise_application_error (-20000, ' the size of the uploaded photo has over 200 KB.) Thanks to upload a smaller image. ") ;
    end if;
    -Mimetype (must be the picture)
    If (insert or update) and: new.photo_name is not null and not
    (
    NVL (:New.photo_mimetype, 'NULL') like '% of the image.
    or
    : new.photo_name as '%.jpg '.
    or
    : new.photo_name as '%.jpeg '.
    or
    : new.photo_name as '%.png '.
    or
    : new.photo_name as '%.gif '.
    or
    : new.photo_name as '%.bmp '.
    or
    : new.photo_name as '%.tif '.
    or
    : new.photo_name as '%.tiff '.
    ) then
    raise_application_error (-20000, ' the uploaded file was not an image.) Thank you to upload an image file. ") ;
    end if;
    end;

    Oracle triggers an error ' •trigger ' SCHEME. " ' BIU_EBA_SME_CONTACTS' is not valid and does not re-validation ". After looking into the trigger and you try to run the script, I get the following error * "Error (13.69): PLS-00357: Table, view or sequence reference ' EBA_SME_ROWKEY_SEQ.» ' NEXTVAL' not allowed in this context. *
    It seems as if line 17 is written by mistake. How can I fix?

    Thank you for your help.

    Published by: AquaNX4 on March 16, 2013 05:30

    The pleasures of learning PL/SQL-understand-you what the question was?

    Initially, this syntax is allowed in 11g

    my_variable := my_sequence.nextval;
    

    I was trying to describe some simple pseudocode for you, that you have tried incorporating - but it is essentially the code that was added.

    declare
      l_key number;
    begin
      select my_sequence.nextval
      into l_key
      from dual;
      my_variable := l_key;
    end;
    

    As described here (but this does not improve performance)
    http://docs.Oracle.com/CD/B28359_01/server.111/B28279/Chapter1.htm#autoId77

    Scott

  • trigger error autnomous mutation! Why not allow select in the trigger body?

    case 1. a user updates the table and this user has not committed, even fire user select request, he would get an old result. but no error.

    case 2. We have table x, trigger appears on the table x as soon as the table is updated to trigger fires. inside the body that we select just for table 'x' it throws error error changing table
    can someone please explain why?

    my example as follows:
    case 1:
    CREATE TABLE MyTable
    (NUMBER of c1);

    INSERT INTO myTable VALUES (1);
    commit;
    INSERT INTO myTable VALUES (2);

    Select * from myTable;
    C1
    ------------
    1




    case 2:
    CREATE TABLE myMaxTable
    (maxValue NUMBER);

    CREATE TABLE MyTable
    (NUMBER of c1);

    INSERT INTO myMaxTable VALUES (NULL);
    COMMIT;

    CREATE OR REPLACE TRIGGER myTrigger
    AFTER ON INSERT myTable
    FOR EACH LINE
    BEGIN
    UPDATE myMaxTable
    SET maxValue = (SELECT MAX (c1) FROM MaTable);
    END;
    /
    INSERT INTO myTable VALUES (1);

    INSERT INTO myTable VALUES (1)
    *
    ERROR on line 1:
    ORA-04091: table HUNBUG. MYTABLE is changing, function of triggering/can not see
    ORA-06512: at "HUNBUG. MON_TRIGGER', line 2
    ORA-04088: error during execution of trigger ' HUNBUG. MYTRIGGER'

    Assume that you are doing something like this:
    You have three records in the table:

    INSERT INTO myTable VALUES (1);
    
    INSERT INTO myTable VALUES (2);
    
    INSERT INTO myTable VALUES (3);
    

    Then do you one insert call to do more than three:

    INSERT INTO myTable
    SELECT c1 + 100
    FROM myTable;
    

    This last call insert inserts 3 records in your table - 101, 102 and 103.

    When you have a trigger FOR EACH ROW, which will be called three times, but there is no way to predict in what order, and when the trigger will fire for example at c1 = 102, the table is the "mutation" - it is located in the heart of a change and you don't know if 101 or 103 or both is in the table. Oracle does not allow you to do a select on the table of this mutation.

    When you remove the FOR EACH ROW clause, the trigger only will be called once at the end of this call to insert, moment in which the table is no longer changing and so your code will be located safely c1 max.

  • Tabular presentation - Trigger error

    Hello

    I have a question about the errors of a trigger seizures in a tabular presentation.

    The situation:
    I use a tabular form for insertion of a row in A table.
    The trigger validates the insert and get a custom error [+ Raise_application_error ("-20001, ' INSERT NOT VALID"); +].
    As I put "+ error message display location Inline in Notification +" with process Error Message: + #SQLERRM_TEXT #+.

    I expect to get "1 error has occurred" with only the message "+ INVALID INSERT +".
    But what I see is
    INSERT NOT VALID ORA-06512: in "SCHEMA. TABLE_TRIGGER', line 23 ORA-04088: error during execution of trigger.
    +' SCHEME. TABLE_TRIGGER' (1st row) +.

    So is it possible to change this type of validation to only see that my custom error message?
    Thanks in advance!

    Hi fyaa,.

    Please take a look at the example of http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_error.htm#CABDJBGJ of error handling function
    Especially the code block

            -- If an ORA error has been raised, for example a raise_application_error(-20xxx, '...')
            -- in a table trigger or in a PL/SQL package called by a process and we
            -- haven't found the error in our lookup table, then we just want to see
            -- the actual error text and not the full error stack with all the ORA error numbers.
            if p_error.ora_sqlcode is not null and l_result.message = p_error.message then
                l_result.message := apex_error.get_first_ora_error_text (
                                        p_error => p_error );
            end if;
    

    is what you are looking for. If you are just curious to see the client error message and do not want to have everything, your error management function might look like

    create or replace function apex_error_handling_example (
        p_error in apex_error.t_error )
        return apex_error.t_error_result
    is
        l_result apex_error.t_error_result;
    begin
        l_result := apex_error.init_error_result (
                        p_error => p_error );
    
        if not p_error.is_internal_error then
            -- If an ORA error has been raised, for example a raise_application_error(-20xxx, '...')
            -- in a table trigger or in a PL/SQL package called by a process and we
            -- haven't found the error in our lookup table, then we just want to see
            -- the actual error text and not the full error stack with all the ORA error numbers.
            if p_error.ora_sqlcode is not null and l_result.message = p_error.message then
                l_result.message := apex_error.get_first_ora_error_text (
                                        p_error => p_error );
            end if;
    
            -- If no associated page item/tabular form column has been set, we can use
            -- apex_error.auto_set_associated_item to automatically guess the affected
            -- error field by examine the ORA error for constraint names or column names.
            if l_result.page_item_name is null and l_result.column_alias is null then
                apex_error.auto_set_associated_item (
                    p_error        => p_error,
                    p_error_result => l_result );
            end if;
        end if;
    
        return l_result;
    end apex_error_handling_example;
    

    Also take a look at my blog announcement at http://www.inside-oracle-apex.com/apex-4-1-error-handling-improvements-part-1/

    Concerning
    Patrick
    -----------
    My Blog: http://www.inside-oracle-apex.com
    APEX Plug-Ins: http://apex.oracle.com/plugins
    Twitter: http://www.twitter.com/patrickwolf

  • DB trigger error - update even table in the script of the trigger

    Hi all
    I have a table tab1, whenever any update is done on this table on column col1 and col2 also needs to get the update. (These are related to user forms can be updated only col1 form frontend)
    So I created a trigger as follows.
    ----------------
    CREATE OR REPLACE TRIGGER tri1
    AFTER UPDATE
    ON tab1
    FOR EACH LINE
    WHERE (NEW.col1 = 'YES')
    DECLARE
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    Tab1 SET col2 = 1 UPDATE
    WHERE transaction_id =: OLD.transaction_id;
    COMMIT;
    END;
    --------
    When there is no update on this table, I get following error. Please let me know if I'm missing something.
    ORA-00060: Deadlock detected while you wait resource
    ORA-06512: at "user1.tab1", line 5
    ORA-04088: error during execution of trigger 'user1.tab1 '.
    Please let me know if I'm not clear. Thank you

    Published by: DharV on August 23, 2011 05:17

    Your transaction_id is unique?

    If this is the case, then you could perhaps use AFTER UPDATE BEFORE UPDATE:

    CREATE OR REPLACE TRIGGER tri1
    BEFORE UPDATE
    ON tab1
    FOR EACH ROW
    WHEN (NEW.col1 = 'YES')
    BEGIN
       :NEW.col2 := 1;
    END;
    

    If your transaction_id is not unique - if you really want to update more than one line in tab1 - your update cannot update the same line that the trigger has responded, even with the use of an autonomous transaction. Then you could combine the BEFORE UPDATE trigger above with your own AFTER UPDATE, but then add ROWID! =: OLD. ROWID to where clause, but it would be a bad idea because some of your lines will be updated in a single transaction and others in another transaction.

    In general the autonomous transaction is not a great way to solve the problem of changing table within a trigger. I hope that you have a unique transaction_id and can do BEFORE the UPDATE - if it is then a better way is to save the update id in an overall picture in FOR EACH ROW triggers, and only then AFTER an UPDATE fire is NOT "for each line" update the list of saved IDs

  • Database trigger error

    Hello
    Version 10204

    I have a 3rd party application that do the following steps:
    1. create an empty table on the fly with the name of dynamics that change.
    2. fill in the table with the records
    3. create an INDEX on the table
    4 collect statistics on the INDEX

    As you can see because there are no statistics on the oracle of the table uses dynamic sampling.

    I would like to get the index and then creating using DB TRIGGER to create statistics on the table.

    I started to write the following trigger and get an error as follows:

     
    SQL> CREATE OR REPLACE TRIGGER SYSTEM.UNICA_STATS 
      2  after create 
      3  ON DATABASE 
      4  DECLARE 
      5  p_host VARCHAR2(512); 
      6  sql_text ora_name_list_t; 
      7  stmt VARCHAR2(2000); 
      8  n number; 
      9  BEGIN 
    10     n := ora_sql_txt(sql_text); 
    11     FOR i IN 1..n LOOP 
    12       stmt := stmt || sql_text(i); 
    13     END LOOP; 
    14         IF (ora_sysevent='CREATE'  and upper(stmt) like '%CREATE INDEX UAC_%' ) THEN 
    15             declare 
    16                v_tab_name  varchar2(50); 
    17             begin 
    18             SELECT TABLE_NAME 
    19             into v_tab_name 
    20             FROM   DBA_INDEXES 
    21             WHERE OWNER = 'CM' 
    22             AND   INDEX_NAME =ora_dict_obj_name; 
    23    --         DBMS_OUTPUT.PUT_LINE('V_TAB_NAME='||V_TAB_NEME); 
    24             RAISE_APPLICATION_ERROR(-20000, 'rAISED BY YOAV!'); 
    25             end; 
    26         END IF; 
    27  END; 
    28  / 
    
    Warning: Trigger created with compilation errors. 
    
    SQL> sho err 
    Errors for TRIGGER SYSTEM.UNICA_STATS: 
    
    LINE/COL ERROR 
    -------- ----------------------------------------------------------------- 
    15/12    PL/SQL: SQL Statement ignored 
    17/19    PL/SQL: ORA-00942: table or view does not exist 
    But:
     
    SQL> SELECT TABLE_NAME 
      2  FROM   DBA_INDEXES 
      3  WHERE OWNER = 'CM' 
      4  and rownum=1; 
    
    TABLE_NAME 
    ------------------------------ 
    UNC_ACCLEAN_FCHID_FAILS 
    Any advice?

    Thank you

    Solomon-

    Excellent point. I was copying just that of the original poster and I did not stop even to think about it.

    Justin

  • After the insert trigger error

    Hello

    I created a trigger after insert according to for me, it's OK, but it show me error can not insert Null in code.
     
    
    
    CREATE OR REPLACE TRIGGER  "AFT_INS_CRM_CUSTOMER_CONTACTS" 
      AFTER INSERT ON FH_TAPROD.CRM_SALES_CUSTOMER_CONTACTS 
    FOR EACH ROW
    DECLARE
    custo_id NUMBER;
    var_code varchar2(8);
    cont_code varchar2(5);
    BEGIN
    
    SELECT CUSTOMER_ID INTO custo_id FROM CRM_SALES_CUSTOMER_CONTACTS WHERE ID =:NEW.ID;
    
      select CODE into var_code from VENDOR_CUSTOMER_MAS where CRM_CUST_ID=custo_id ;
    
      SELECT LPAD ( NVL(MAX(CONTACT_CODE), 0)+ 1, 5, '0') into cont_code FROM vendor_customer_contact
      
      insert into VENDOR_CUSTOMER_CONTACT(SBU_CODE ,CODE,CONTACT_CODE, CONTACT_NAME ,PHONE_NO1 ,MOBILE_NO ,EMAIL, ADDRESS1,CUST_ID,UPLOAD_CRM) 
       values('0002',var_code,cont_code,:NEW.CONTACT_NAME,:NEW.CONTACT_PHONE,:NEW.CONTACT_CELL,:NEW.CONTACT_EMAIL,:NEW.CONTACT_ADDRESS,custo_id,'CRM');
    
    
    END; 
    CREATE TABLE  "CRM_SALES_CUSTOMER_CONTACTS" 
       (     "ID" NUMBER, 
         "CUSTOMER_ID" NUMBER, 
         "CONTACT_NAME" VARCHAR2(255), 
         "CONTACT_EMAIL" VARCHAR2(255), 
         "CONTACT_PHONE" VARCHAR2(255), 
         "CONTACT_CELL" VARCHAR2(255), 
         "CONTACT_ADDRESS" VARCHAR2(4000), 
          PRIMARY KEY ("ID") ENABLE
       )
    /
    INSERT INTO CRM_SALES_CUSTOMER_CONTACTS VALUES (204414862717175278810736770347803084847, 204232590877603599356756434170666837075, 'SANJAY',    '[email protected]', 1246456, 57152357,'Near Post Office');
    CREATE OR REPLACE TRIGGER  "BIU_CRM_SALES_CUST_CONTACTS" 
    BEFORE INSERT OR UPDATE ON CRM_SALES_CUSTOMER_CONTACTS
        FOR EACH ROW
    begin
        if inserting and :new.id is null then
            select to_number(sys_guid(),'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') into :new.id from dual;
        end if;
        if inserting then
            :new.created_by := nvl(v('APP_USER'),USER);
            :new.created_on := sysdate;
        end if;
        if updating then
            :new.updated_by := nvl(v('APP_USER'),USER);
            :new.updated_on := sysdate;
        end if;
    end;
    My after insert a table
    CREATE TABLE  "VENDOR_CUSTOMER_CONTACT" 
       (     "SBU_CODE" VARCHAR2(4) NOT NULL ENABLE, 
         "CODE" VARCHAR2(8) NOT NULL ENABLE, 
         "CONTACT_CODE" VARCHAR2(5) NOT NULL ENABLE, 
         "CONTACT_NAME" VARCHAR2(1000) NOT NULL ENABLE, 
         "PHONE_NO1" VARCHAR2(100), 
         "MOBILE_NO" VARCHAR2(25), 
         "EMAIL" VARCHAR2(1000), 
         "ADDRESS1" VARCHAR2(4000), 
         "CUST_ID" NUMBER, 
         "UPLOAD_CRM" VARCHAR2(10), 
          CONSTRAINT "VCV_PK" PRIMARY KEY ("SBU_CODE", "CODE", "CONTACT_CODE") ENABLE
       )
    ORA-01400: cannot insert NULL into ("FH_TAPROD"."VENDOR_CUSTOMER_CONTACT"."CODE") ORA-06512: at "FH_TAPROD.AFT_INS_CRM_CUSTOMER_CONTACTS", line 30 ORA-04088: error during execution of trigger 'FH_TAPROD.AFT_INS_CRM_CUSTOMER_CONTACTS'
    How to solve it.

    Thank you

    Published by: 805629 on January 14, 2011 01:26

    This is the error...

    SELECT CUSTOMER_ID INTO custo_id FROM CRM_SALES_CUSTOMER_CONTACTS WHERE ID =: NEW.ID;

    Is there a reason why not to use: NEW. CUSTOMER_ID rather the query?

  • TRIGGER ERROR: bad bind variable

    Hello

    I just start with oracle and I try to do the same thing as auto_increment in mysql by creating this sequence and the trigger but the trigger, I get the following error:

    error:
    -----
    PLS-00049: bad bind variable 'TAKEOVER_USERS.TAKEOVER_UID'
    This is the code for the relaxation, table and sequence:

    triggering factor:
    ---------
    CREATE OR REPLACE TRIGGER  "TAKEOVER_USERS_T1" 
    BEFORE
    insert on "TAKEOVER_USERS"
    for each row
    begin
    select TAKEOVER_UID.nextval into :takeover_users.TAKEOVER_UID from dual;
    end;
    Table:
    ------
    CREATE TABLE  "TAKEOVER_USERS" 
       ( "TAKEOVER_UID" NUMBER NOT NULL ENABLE, 
     "TAKEOVER_FBID" VARCHAR2(20) NOT NULL ENABLE, 
     "takeover_accepted_terms" NUMBER(1,1) NOT NULL ENABLE, 
     "takeover_lastName" VARCHAR2(30), 
     "takeover_firstName" VARCHAR2(30), 
     "takeover_country" VARCHAR2(40), 
     "takeover_session" VARCHAR2(50) NOT NULL ENABLE, 
     "takeover_created" TIMESTAMP (6) NOT NULL ENABLE, 
      CONSTRAINT "takeover_users_PK" PRIMARY KEY ("TAKEOVER_UID") ENABLE
       )
    sequence:
    -----------
    CREATE SEQUENCE   "TAKEOVER_UID"  MINVALUE 1 MAXVALUE 99999999999999 INCREMENT BY 1 START WITH 1 NOCACHE  NOORDER  NOCYCLE
    Any idea what I need to change to make it work?
    Thank you!

    Christine

    If your DB is 11g, you can try this

    CREATE OR REPLACE TRIGGER  "TAKEOVER_USERS_T1"
    BEFORE
    insert on "TAKEOVER_USERS"
    for each row
    begin
    :NEW.TAKEOVER_UID:=TAKEOVER_UID.nextval;
    end;
    

    If 10g or more...

    CREATE OR REPLACE TRIGGER  "TAKEOVER_USERS_T1"
    BEFORE
    insert on "TAKEOVER_USERS"
    for each ROW
    BEGIN
    SELECT TAKEOVER_UID.NEXTVAL INTO :NEW.TAKEOVER_UID FROM dual;
    end;
    

    Kind regards
    Prazy

Maybe you are looking for