Updating index in a trigger

Does anyone have any code snippets for a trigger that updates the index upon insert/delete/update of a row in a table?
I have this so far:
CREATE OR REPLACE TRIGGER prod_search_index
AFTER INSERT OR UPDATE OR DELETE ON PRODUCT
BEGIN
ctx_ddl.sync_index(PRODUCTMANUFACTURER_INDEX);
ctx_ddl.sync_index(PRODUCTNAME_INDEX);
ctx_ddl.sync_index(PRODUCTVERSION_INDEX);
commit;
END;
but it doesn't like ctx_ddl too much and says it must be defined. Am I missing something?

A couple of things you could check/try.
1. Privileges for the user who is trying to run this program.
2. Qualify the procedure call with the owner of the packaged procedure.
For example:
owner.package.procedure(parameter 1, parameter 2)

Similar Messages

  • What privs r required to run Alter table truncate partition update indexes?

    I rebuilt the indexes on the table. Know my problem is that when I truncate a partition on the table the unique index whic consist of the primary key fields becomes unusable which causes my to have to rebuild it after each truncate. I tried to runm the following statement from the master schema on but get
    an insufficient privs error when I use "update indexes":
    Alter table schema_name.table_name truncate partition partition_name storage update indexes;
    What priv does master need to perform statement successfully when there's data in it?
    Does using 'update indexes' needs extra priveleges?
    Thanks in Advance
    Gagan

    Hi Its Oracle 10.2.0.4 64 Bit on HP UX.
    I dont have the exact error as I got this much information only from the end user....It will be couple of hours more then he will be available again
    ok so for Truncate we need 'Drop any' privs but to use clause 'update indexes' alongwith do we need some extra privelege?
    Thanks again
    Gagan

  • How to update two tables with trigger

    Hi:
    how to update two tables with trigger ?
    I have two tables :
    (1)ASIA
    MI number;
    (2)ASIA_P
    ID number;
    When I insert a new value into the asia.MI ,I also can
    insert the same value into the asia_p.id field.
    I have write a trigger as follows but it does't work.
    create or replace trigger MI_TRG
    before insert on asia
    for each row
    declare
    seq number;
    begin
    select MI_SEQ.Nextval into seq from dual;
    :new.MI:=seq;
    insert into ASIA_PRO(MI_ID)
    values
    (seq);
    end MI_TRG;
    How to realize it ?
    thanks
    zzm

    Why do you say it does not work?

  • Update index rates, table:ORTT

    Hello,
    The SBObob object contains function: SetCurrencyRates -  add/update currencies rate.
    I need to to the same, but with indexses
    Does anyone know how to do this?
    thanks
    Tami

    Tami,
    This is a duplicate message to this one ...
    Add/Update Indexes Rates via DI, table:ORTT
    Please close one of them.
    Eddy

  • Synching index with a trigger

    Hi all,
    I have the following trigger setup:
    CREATE OR REPLACE TRIGGER update_file_content
    AFTER INSERT OR UPDATE OR DELETE ON test_files
    BEGIN
    if deleting then
    ctx_ddl.optimize_index('file_content_idx','FULL');
    else
    ctx_ddl.sync_index('file_content_idx');
    end if;
    END;
    Problem is that whenever I insert/update/delete something in the table I get the following errors:
    17:47:04 Error: ORA-20000: Oracle Text error:
    DRG-51300: error getting dml Queue lock
    ORA-04092: cannot COMMIT in a trigger
    ORA-06512: at "CTXSYS.DRUE", line 160
    ORA-06512: at "CTXSYS.CTX_DDL", line 539
    ORA-06512: at "UPDATE_FILE_CONTENT", line 5
    ORA-04088: error during execution of trigger 'UPDATE_FILE_CONTENT'
    Those comments alone work perfect. So, actually how can I synch my index to be uptodate all the time?
    Nitai

    I left out a couple of single quotes. Please see the corrected code in the demo below.
    scott@ORA92> CREATE TABLE test_files
      2    (test_col VARCHAR2(60))
      3  /
    Table created.
    scott@ORA92> CREATE INDEX file_content_idx
      2  ON test_files (test_col)
      3  INDEXTYPE IS CTXSYS.CONTEXT
      4  /
    Index created.
    scott@ORA92> CREATE OR REPLACE TRIGGER update_file_content
      2    AFTER INSERT OR UPDATE OR DELETE ON test_files
      3  DECLARE
      4    v_job NUMBER;
      5  BEGIN
      6    if deleting then
      7        DBMS_JOB.SUBMIT
      8          (v_job, 'ctx_ddl.optimize_index(''file_content_idx'',''FULL'');', SYSDATE);
      9    else
    10        DBMS_JOB.SUBMIT
    11          (v_job, 'ctx_ddl.sync_index(''file_content_idx'');', SYSDATE);
    12    end if;
    13  END;
    14  /
    Trigger created.
    scott@ORA92> SHOW ERRORS
    No errors.
    scott@ORA92> INSERT INTO test_files (test_col)
      2  VALUES ('first inserted test record')
      3  /
    1 row created.
    scott@ORA92> COMMIT
      2  /
    Commit complete.
    scott@ORA92> EXEC DBMS_LOCK.SLEEP (15)
    PL/SQL procedure successfully completed.
    scott@ORA92> SELECT token_text FROM dr$file_content_idx$i
      2  /
    TOKEN_TEXT
    FIRST
    INSERTED
    RECORD
    TEST
    scott@ORA92> SELECT * FROM test_files
      2  WHERE  CONTAINS (test_col, 'first') > 0
      3  /
    TEST_COL
    first inserted test record
    scott@ORA92>

  • BPL Sales orders: Updating index tables

    Hello forum,
    After using BPL to copy sales orders, index tables are not updated. Examples of these tables are VAKPA (sales index by partner function), VAPMA (sales index by material), VLPMA (deliveries by material) or VRPMA (billing documents by material).
    To correct this what we do is run program RVV05IVB (Reorganization of SD Document Indices) but this report is very time consuming. (it is not that easy to know the documents numbers for all sales / deliveries / billing docs that were copied so we have to run the report for all documents; even if we knew the document numbers, though, the report is very slow because these tables do not have an index by document).
    Is this the way to do it, or are other people working differently?
    Or should these tables be included in the context?
    Thanks in advance,
    Rui Dantas

    >
    Nico Gaertner wrote:
    > Alternatively you can also create this index on the receiver side and connect these tables with the Table VBUK in the BPL datamodel.
    > Nico
    In this case you mean sender system, right?
    The access won't be that bad if you choose the right table to link: VBAP-MATNR for VAPMA, or VBPA-KUNNR + VBPA-PARVW for VAKPA. I'll try in our system.
    It would be even better, of course, if we could link from more than one table (e.g. VBAK + VBAP to VAPMA). This is not possible, right?

  • Auto update of timestamp with trigger

    I have a timestamp data element that we want to be updated via a trigger whenever a row is inserted or updated.
    My trigger looks something like -
    create trigger "name"
    before insert or update on "table"
    for each row
    begin
    :new.create_timestamp:=systimestamp;
    end
    create_timestamp is defined as timestamp(9)
    everything compiles and we can insert data without problem but the create_timestamp element is null. What wrong here?
    thanks

    What version of Oracle are you using? If you are at 8i or lower, your column datatype should be DATE and you should be assigning SYSDATE to the value (e.g., select SYSDATE from dual;). I don't know the answer if you're on 9i.
    Tim

  • PL/SQL Trying to update a table through trigger on the same table

    Hi everyone my name is Edwin and I'm new to this forum. I hope I can learn a lot from this community and over time contribute to it.
    The problem I'm facing at the moment is a tough one. I need to update a table (table a) with a value called block_id. This block_id is generated by a procedure I have written myself, the end result is stored in another table (table b). This block_id needs to be generated after certain rows of table a get updated with a trans_id. The trans_id is all the same for these rows in table a, but the generated block_id isn't. In my code I use an after update on collumn a of table a trigger. So if the the collumn gets updated the trigger fires. The trigger calls the procedure that generates the block_id and the procedure generates table b with all the block_id's. But then I want to update the rows in table a with the generated block_id in table b. The problem is that this self-deadlocks.
    You might think that this would call a recursive trigger, but I have written code in the trigger that checks if the block_id isn't allready filled in on table a.
    Also I really need all the values wich get updated (table a), so I believe a before update is also out of the question.
    And the first update of table a is done through an erp-packet and I can't get at that code, otherwise I would just have run my code from there.
    Message was edited by:
    user625855

    CREATE OR REPLACE TRIGGER block_id_trigger AFTER UPDATE ON unload_details_tab
    DECLARE
    current_transport_id NUMBER;
    check_value NUMBER;
    check_block_id NUMBER;
    PRAGMA AUTONOMOUS_TRANSACTION;
    BEGIN
    current_transport_id := get_curent_trans_id; --function that gets the current transport_id
    check_value := check_site_and_directive(current_transport_id); --function checks if this transport_id should have a block_id
    check_block_id := check_for_block_id(current_transport_id); --function checks if there isn't allready a block_id set.
    IF check_value = 1 AND check_block_id = 0 THEN
    create_blok_id_table(current_transport_id); --this procedure creates the blok_id in temptable
    UPDATE unload_details_tab a SET a.block_id = (SELECT DISTINCT b.blok_id FROM temptable b WHERE b.mark = a.mark_1) WHERE a.transport_id = current_transport_id; --this statement should update the table back, if I leave it out everything works fine, but when I leave it I get the self-deadlock error.
    ELSE
    null;
    END IF;
    END block_id_trigger;
    Ok, I cleaned the code somewhat.
    user625855

  • Updating index from Word file in Book feature

    I prepared a book using the book feature. 15 chapter files making up the book. The client is going to supply the Index as a Word file with page numbers from his book's word file, which I was hoping to spill into a file in the book and Update the page numbers. I have done this when the book is all one file, but will it work in the book feature? Also, what if a thread is broken somewhere (there were lots of photographs and I think that may have happened a few times). Will that effect the indexes ability to update the page numbers (provided it even works in the Book feature)?
    Thanks!

    Little Toddler wrote:
    The client is going to supply the Index as a Word file with page numbers from his book's word file ...
    That's No Good. The page numbers as they were in the original Word file are worthless.
    .. which I was hoping to spill into a file in the book and Update the page numbers.
    InDesign cannot update the page numbers in an index that was created with Word.
    I have done this when the book is all one file, but will it work in the book feature?
    Uh. Perhaps you did not (see above). Only if you made this index entirely in InDesign is when that's possible. (But yeah, "Include Book" is an option in the Generate Index dialog.)
    Also, what if a thread is broken somewhere (there were lots of photographs and I think that may have happened a few times). Will that effect the indexes ability to update the page numbers (provided it even works in the Book feature)?
    Proper or improper threading is not a problem.
    The problem is you must distinguish between an index made in Word and one made in InDesign -- and I mean "made with", not just "typed in". If your writer supplies you an index made in Word, you can throw it out of the window. What good are his page numbers to you? You can only mimick his index (sort of) if your processed InDesign files still contain the original Index Markers that the author used in Word, and then you are using the same workflow, not "updating the author's index".
    If there are no index markers in your InDesign files, that's where it stops for you. Perhaps you want to insert them, one by one, in their original location (using the supplied index as a guide) -- only then you can create an up-to-date index with InDesign and using your page numbers.
    There is another option: if your author used Word's features to generate the index with, he could try the opposite. That is, you hand him a PDF of the latest version of your book, and he inserts page breaks and adjusts page numbering in his Word document to match yours, word by word. This can be done quite fast because all other formatting is not important -- it's the What's on this Page Number that counts. When done, the author can use Word again to re-generate the index, and hey! the page numbers will match the final version!
    Of course this only works when the author actually used Word's native indexing facility -- if he typed in each entry and its associated page numbers, you got yourself quite a job trying to find what word went where in your version.

  • TREX not updating index of UME

    We have created an index of the UME users for the Who's Who search functionality.  Our UME is connected to an Active Directory LDAP.  Everything is working except that changes made to AD are not being updated in the index.  The index and its data source are scheduled to run its crawler every night.  In particular, it is the telephone property that we noticed is not updating.
    What am I missing?
    Maximum points awarded to the first correct solution.

    Here you go.  You can see where PRINCIPAL_MODIFY_DATE has been mapped.  All the other mappings are pretty standard for AD.
    <?xml version="1.0" encoding="UTF-8"?>
    <!-- $Id: //shared_tc/com.sapall.security/630_SP_COR/src/_deploy/dist/configuration/shared/dataSourceConfiguration_ads_readonly_db.xml#6 $ from $DateTime: 2004/08/20 09:55:24 $ ($Change: 17140 $) -->
    <!DOCTYPE dataSources SYSTEM "dataSourceConfiguration.dtd">
    <dataSources>
        <dataSource id="PRIVATE_DATASOURCE" className="com.sap.security.core.persistence.datasource.imp.DataBasePersistence" isReadonly="false" isPrimary="true">
            <homeFor>
                <principals>
                    <principal type="group"/>
                    <principal type="user"/>
                    <principal type="account"/>
                    <principal type="team"/>
                    <principal type="ROOT"/>
                    <principal type="OOOO"/>
                </principals>
            </homeFor>
            <notHomeFor/>
            <responsibleFor>
                <principals>
                    <principal type="group"/>
                    <principal type="user"/>
                    <principal type="account"/>
                    <principal type="team"/>
                    <principal type="ROOT"/>
                    <principal type="OOOO"/>
                </principals>
            </responsibleFor>
            <privateSection/>
        </dataSource>
        <dataSource id="XXXXXXXXX" className="com.sap.security.core.persistence.datasource.imp.LDAPPersistence" isReadonly="true" isPrimary="true">
            <homeFor/>
            <responsibleFor>
                <principal type="account">
                    <nameSpace name="com.sap.security.core.usermanagement">
                        <attributes>
                            <attribute name="j_user"/>
                            <attribute name="logonalias"/>
                            <attribute name="j_password"/>
                            <attribute name="userid"/>
                        </attributes>
                    </nameSpace>
                </principal>
                <principal type="user">
                    <nameSpaces>
                        <nameSpace name="com.sap.security.core.usermanagement">
                            <attributes>
                                <attribute name="firstname" populateInitially="true"/>
                                <attribute name="displayname" populateInitially="true"/>
                                <attribute name="lastname" populateInitially="true"/>
                                <attribute name="fax"/>
                                <attribute name="email"/>
                                <attribute name="title"/>
                                <attribute name="department"/>
                                <attribute name="description"/>
                                <attribute name="mobile"/>
                                <attribute name="telephone"/>
                                <attribute name="streetaddress"/>
                                <attribute name="city"/>
                                <attribute name="company"/>
                                <attribute name="manager"/>
                                <attribute name="uniquename" populateInitially="true"/>
                                <attribute name="kpnprefix"/>
                                <attribute name="krb5principalname"/>
                                <attribute name="dn"/>
                                <attribute name="country"/>
                                <attribute name="jobtitle"/>
                                <attribute name="zip"/>
                                <attribute name="state"/>
                                <attribute name="pobox"/>
                                <attribute name="PRINCIPAL_MODIFY_DATE"/>
                            </attributes>
                        </nameSpace>
                        <nameSpace name="com.sap.security.core.usermanagement.relation">
                            <attributes>
                                <attribute name="PRINCIPAL_RELATION_PARENT_ATTRIBUTE"/>
                            </attributes>
                        </nameSpace>
                        <nameSpace name="$usermapping$">
                            <attributes>
                                <attribute name="REFERENCE_SYSTEM_USER"/>
                            </attributes>
                        </nameSpace>
                    </nameSpaces>
                </principal>
                <principal type="group">
                    <nameSpaces>
                        <nameSpace name="com.sap.security.core.usermanagement">
                            <attributes>
                                <attribute name="displayname" populateInitially="true"/>
                                <attribute name="description" populateInitially="true"/>
                                <attribute name="uniquename"/>
                            </attributes>
                        </nameSpace>
                        <nameSpace name="com.sap.security.core.usermanagement.relation">
                            <attributes>
                                <attribute name="PRINCIPAL_RELATION_MEMBER_ATTRIBUTE"/>
                                <attribute name="PRINCIPAL_RELATION_PARENT_ATTRIBUTE"/>
                            </attributes>
                        </nameSpace>
                        <nameSpace name="com.sap.security.core.bridge">
                            <attributes>
                                <attribute name="dn"/>
                            </attributes>
                        </nameSpace>
                    </nameSpaces>
                </principal>
            </responsibleFor>
            <attributeMapping>
                <principals>
                    <principal type="account">
                        <nameSpaces>
                            <nameSpace name="com.sap.security.core.usermanagement">
                                <attributes>
                                    <attribute name="j_user">
                                        <physicalAttribute name="samaccountname"/>
                                    </attribute>
                                    <attribute name="logonalias">
                                        <physicalAttribute name="samaccountname"/>
                                    </attribute>
                                    <attribute name="j_password">
                                        <physicalAttribute name="unicodepwd"/>
                                    </attribute>
                                    <attribute name="userid">
                                        <physicalAttribute name="*null*"/>
                                    </attribute>
                                </attributes>
                            </nameSpace>
                        </nameSpaces>
                    </principal>
                    <principal type="user">
                        <nameSpaces>
                            <nameSpace name="com.sap.security.core.usermanagement">
                                <attributes>
                                    <attribute name="firstname">
                                        <physicalAttribute name="givenname"/>
                                    </attribute>
                                    <attribute name="displayname">
                                        <physicalAttribute name="displayname"/>
                                    </attribute>
                                    <attribute name="lastname">
                                        <physicalAttribute name="sn"/>
                                    </attribute>
                                    <attribute name="fax">
                                        <physicalAttribute name="facsimiletelephonenumber"/>
                                    </attribute>
                                    <attribute name="uniquename">
                                        <physicalAttribute name="samaccountname"/>
                                    </attribute>
                                    <attribute name="loginid">
                                        <physicalAttribute name="*null*"/>
                                    </attribute>
                                    <attribute name="email">
                                        <physicalAttribute name="mail"/>
                                    </attribute>
                                    <attribute name="mobile">
                                        <physicalAttribute name="mobile"/>
                                    </attribute>
                                    <attribute name="telephone">
                                        <physicalAttribute name="telephonenumber"/>
                                    </attribute>
                                    <attribute name="department">
                                        <physicalAttribute name="department"/>
                                    </attribute>
                                    <attribute name="description">
                                        <physicalAttribute name="description"/>
                                    </attribute>
                                    <attribute name="streetaddress">
                                        <physicalAttribute name="streetaddress"/>
                                    </attribute>
                                    <attribute name="city">
                                        <physicalAttribute name="l"/>
                                    </attribute>
                                    <attribute name="company">
                                        <physicalAttribute name="company"/>
                                    </attribute>
                                    <attribute name="manager">
                                        <physicalAttribute name="manager"/>
                                    </attribute>
                                    <attribute name="kpnprefix">
                                        <physicalAttribute name="samaccountname"/>
                                    </attribute>
                                    <attribute name="krb5principalname">
                                        <physicalAttribute name="userprincipalname"/>
                                    </attribute>
                                    <attribute name="dn">
                                        <physicalAttribute name="distinguishedname"/>
                                    </attribute>
                                    <attribute name="country">
                                        <physicalAttribute name="country"/>
                                    </attribute>
                                    <attribute name="jobtitle">
                                        <physicalAttribute name="title"/>
                                    </attribute>
                                    <attribute name="zip">
                                        <physicalAttribute name="postalCode"/>
                                    </attribute>
                                    <attribute name="state">
                                        <physicalAttribute name="st"/>
                                    </attribute>
                                    <attribute name="pobox">
                                        <physicalAttribute name="postOfficeBox"/>
                                    </attribute>
                                    <attribute name="PRINCIPAL_MODIFY_DATE">
                                        <physicalAttribute name="modifyTimeStamp"/>
                                    </attribute>
                                </attributes>
                            </nameSpace>
                            <nameSpace name="com.sap.security.core.usermanagement.relation">
                                <attributes>
                                    <attribute name="PRINCIPAL_RELATION_PARENT_ATTRIBUTE">
                                        <physicalAttribute name="memberof"/>
                                    </attribute>
                                </attributes>
                            </nameSpace>
                            <nameSpace name="$usermapping$">
                                <attributes>
                                    <attribute name="REFERENCE_SYSTEM_USER">
                                        <physicalAttribute name="sapusername"/>
                                    </attribute>
                                </attributes>
                            </nameSpace>
                        </nameSpaces>
                    </principal>
                    <principal type="group">
                        <nameSpaces>
                            <nameSpace name="com.sap.security.core.usermanagement">
                                <attributes>
                                    <attribute name="displayname">
                                        <physicalAttribute name="displayname"/>
                                    </attribute>
                                    <attribute name="description">
                                        <physicalAttribute name="description"/>
                                    </attribute>
                                    <attribute name="uniquename" populateInitially="true">
                                        <physicalAttribute name="cn"/>
                                    </attribute>
                                </attributes>
                            </nameSpace>
                            <nameSpace name="com.sap.security.core.usermanagement.relation">
                                <attributes>
                                    <attribute name="PRINCIPAL_RELATION_MEMBER_ATTRIBUTE">
                                        <physicalAttribute name="member"/>
                                    </attribute>
                                    <attribute name="PRINCIPAL_RELATION_PARENT_ATTRIBUTE">
                                        <physicalAttribute name="memberof"/>
                                    </attribute>
                                </attributes>
                            </nameSpace>
                            <nameSpace name="com.sap.security.core.bridge">
                                <attributes>
                                    <attribute name="dn">
                                        <physicalAttribute name="*null*"/>
                                    </attribute>
                                </attributes>
                            </nameSpace>
                        </nameSpaces>
                    </principal>
                </principals>
            </attributeMapping>
            <privateSection>
                <ume.ldap.access.server_type>MSADS</ume.ldap.access.server_type>
                <ume.ldap.access.context_factory>com.sun.jndi.ldap.LdapCtxFactory</ume.ldap.access.context_factory>
                <ume.ldap.access.authentication>simple</ume.ldap.access.authentication>
                <ume.ldap.access.flat_group_hierachy>true</ume.ldap.access.flat_group_hierachy>
                <ume.ldap.access.user_as_account>true</ume.ldap.access.user_as_account>
                <ume.ldap.access.dynamic_groups>false</ume.ldap.access.dynamic_groups>
                <ume.ldap.access.ssl_socket_factory>com.sap.security.core.server.https.SecureConnectionFactory</ume.ldap.access.ssl_socket_factory>
                <ume.ldap.access.objectclass.user>User</ume.ldap.access.objectclass.user>
                <ume.ldap.access.objectclass.uacc>User</ume.ldap.access.objectclass.uacc>
                <ume.ldap.access.objectclass.grup>Group</ume.ldap.access.objectclass.grup>
                <ume.ldap.access.naming_attribute.user>cn</ume.ldap.access.naming_attribute.user>
                <ume.ldap.access.auxiliary_naming_attribute.user>samaccountname</ume.ldap.access.auxiliary_naming_attribute.user>
                <ume.ldap.access.naming_attribute.uacc>cn</ume.ldap.access.naming_attribute.uacc>
                <ume.ldap.access.auxiliary_naming_attribute.uacc>samaccountname</ume.ldap.access.auxiliary_naming_attribute.uacc>
                <ume.ldap.access.naming_attribute.grup>cn</ume.ldap.access.naming_attribute.grup>
                <ume.ldap.access.extended_search_size>200</ume.ldap.access.extended_search_size>
                <ume.ldap.access.server_name>XXXXXXXXX</ume.ldap.access.server_name>
                <ume.ldap.access.server_port>XXXXX</ume.ldap.access.server_port>
                <ume.ldap.access.user>XXXXXXXXX</ume.ldap.access.user>
                <ume.ldap.access.password>XXXXXXXX</ume.ldap.access.password>
                <ume.ldap.access.base_path.user>XXXXXX</ume.ldap.access.base_path.user>
                <ume.ldap.access.base_path.grup>XXXXXX</ume.ldap.access.base_path.grup>
                <ume.ldap.negative_user_filter></ume.ldap.negative_user_filter>
            </privateSection>
        </dataSource>
    </dataSources>

  • Updating Sybase from Oracle trigger

    Hi
    I have 2 databases: Oracle 8i and Sybase, both with a identical schema (same tables).
    An app will be updating the Oracle database, and I would like that automatically the Sybase database be updated accordingly, to keep them synchronized.
    I am thinking about using java stored procedures and JDBC to access Sybase, that would be called from triggers. Is this possible? Where could I find some examples?
    Thanks
    Luis Cabral

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Swapnil:
    I am writing a trigger on a table and need to update and insert data in some other table, but for some unknown reason I am not able to do this. I tried catching all the errors but find none as such.
    This is the scenario...Consider Table A and Table B...the trigger is being written on Table A...On insert in table A, it should read table B and do some checks and update/insert in table B with the values fetched from table A. I have done it by writing a trigger on table A in which i read the table B and also update and insert in the Table B by referencing the values :new and :old from Table B(this is not mutating is it?? i dont get any mutating error), but this doesn't work....any ideas.suggestions are appreciated.....
    Swapnil
    [email protected]<HR></BLOCKQUOTE>
    Use table A values as 'NEW' and table B values as 'OLD'.
    null

  • Update by after insert trigger

    I need to update each new inserted row of data by checking if there were same values in the table. So I tried the After Insert Trigger with the code below :
    CREATE OR REPLACE TRIGGER approve_checker
    after insert on TBL_BILL
    for each row
    declare
    counter integer;
    begin
    SELECT COUNT() INTO counter FROM TBL_BILL WHERE issue_date=:NEW.issue_date AND wagon_no=:NEW.wagon_no ;*
    IF( counter > 1)
    THEN
    UPDATE TBL_BILL SET approved = 2 WHERE id = :NEW.id;
    END IF;
    end approve_checker;
    But errors accured :
    ORA-04091: table RAIL.BILL is mutating, trigger/function may not see it
    ORA-06512: at "RAIL.APPROVE_CHECKER", line 4
    ORA-04088: error during execution of trigger 'RAIL.APPROVE_CHECKER'
    Any help appreciated.

    You cannot SELECT from the table on which the row-level trigger is defined, nor can you UPDATE a table on which the row-level trigger is defined. If you are inserting multiple rows in a single INSERT statement, Oracle can't be sure what rows to update and/or select.
    Is there a reason that you wouldn't just create a unique constraint to enforce this condition?
    Justin

  • HTML DB Insert Update field by a trigger -- Repost

    I have a table that has 3 columns, they all not NULL.
    User_name, Update_date, Update_By
    I want to enter user name only and the Database trigger will update the other two fields. I used SQL - Command Processor I could achieve the purpose, but I could NOT do it in the HTML DB form. I mean the HTML DB form seem did NOT trigger the trigger in the database.
    Why? it work for me before.
    Here is my trigger
    create trigger "Update_date_by"
    before insert on "SERVICES"
    for each row
    begin
    :new.UPDATE_DATE := SYSDATE;
    :new.Update_by := nvl(v('app_user'),user);
    end;

    Here's one of my triggers, which works just fine.
    CREATE OR REPLACE TRIGGER "CONTACTS_DEVICE_BI"
    BEFORE
    insert on "CONTACTS_DEVICE"
    for each row
    begin
    :new.created_by := NVL (v ('APP_USER'), USER);
    :new.created_on := sysdate;
    end;
    Looks pretty much like yours except for the 'or replace' clause in the first line.
    Are you getting any kind of errors anywhere? If you're not getting any errors and the trigger doesn't appear to be making the appropriate entries in the table then it's probably not firing at all - which means it's somehow gotten disconnected from the target table somehow.
    Look in the object browser of the SQL workshop and select Triggers from the list. Then make sure the trigger is compiled with no errors.
    Earl

  • Fetch Insert / Update Query From Table Trigger

    Hi everyone !,
    I have a situation, is there any way where I can get insert/update query by before-insert / after insert trigger when a user inserts/updates any row in the table.
    Plz....help me....champs.....
    Regards,
    Naushad

    That was a nice thing but it works only on some oracle 9i with DML statements.
    On database versions 9.2.0.1 to 9.2.0.6 ora_sql_text works and returns the calling text for dml triggers, where as starting from 9.2.0.7 the behavior has changed and returns NULL.
    Cause
    This issue had surfaced from 9.2.0.7.0 patchset. After discussions in Bug 4171597 which was closed as a duplicate of Bug 4230721 it was concluded that it was the expected behavior i.e ORA_SQL_TXT should return null when dml triggers are used.
    ORA_SQL_TXT is a "System defined event attribute" and is supposed to work only with "System triggers". This is also what the Documentation says - "Application Developers Guide : Fundamentals(9.2)
    Chapter 16 Working with System events".
    Bye Alessandro

  • HTML DB Insert Update field by a trigger

    I have a table that has 3 columns, they all not NULL.
    User_name, Update_date, Update_By
    I want to enter user name only and the Database trigger will update the other two fields. I used SQL - Command Processor I could achieve the purpose, but I could do it in the form. I mean the form seem did trigger the trigger in the database.
    Why? it work for me before.
    create trigger "Update_date_by"
    before insert on "SERVICES"
    for each row
    begin
    :new.UPDATE_DATE := SYSDATE;
    :new.Update_by := nvl(v('app_user'),user);
    end;

    Sorry for my English
    Here is correction:
    I have a table that has 3 columns, they all not NULL.
    User_name, Update_date, Update_By
    I want to enter user name only and the Database trigger will update the other two fields. I used SQL - Command Processor I could achieve the purpose, but I could NOT do it in the form. I mean the form seem did NOT trigger the trigger in the database.
    Why? it work for me before.
    create trigger "Update_date_by"
    before insert on "SERVICES"
    for each row
    begin
    :new.UPDATE_DATE := SYSDATE;
    :new.Update_by := nvl(v('app_user'),user);
    end;

Maybe you are looking for

  • Impossible to install iTunes

    Hello, I have a problem with the installation of Itunes on my XP pro SP3. When I launch the install, a few moment later I have this message: "Impossible to open this key HKEYLOCALMACHINE\SOFTWARE\Appla Computer,Inc.\QuickTime\Installed Files\QTPlugin

  • Impossible to search in WBS Hierarchy

    Hello, We are using the standard WBS Hierarchy [WBSH] on master data 0WBS_ELEMT.  In Query Designer, when we want to perform a restriction of values on a particular WBS Hierarchy node, using Search fonctionnality in restrict menu, it is impossible to

  • Info record price picking.

    Hi Currently I blocked manual entry of price in PO. The price should pick only from info record, if info record is not there for the material then it should through an error message. I have already made Message No: 06 136 No info record exists for it

  • Non-repeating multiple key press issues

    My g/f has a G4 Titanium Onyx and seemingly randomly, the keyboard has started acting up. The bottom row of keys works, but anything above it gives out multiple characters on a single keypress. These are non-repetative. For example hitting 'l' doesn'

  • Coding conventions for SERVLETS

    Where to find coding conventions for Java Servlets ?