Trigger and rollback on oracle 9i

hi,
i work on oracle 9i.
in my database i import csv file in en temporary table and make a trigger to update 2 table after insert.
i want to make a csv file wich contain each not good row.
i search a way to cancel the first update if the second update is not good
i try to use a autonomous transaction but there is an error...maybe you can help me and give me a solution to my probleme.
my trigger's code
declare
gache NUMBER;lieu NUMBER;reference NUMBER;test UTL_FILE.FILE_TYPE; erreur NUMBER;
v_file UTL_FILE.FILE_TYPE;
PRAGMA AUTONOMOUS_TRANSACTION;
begin
commit;
SELECT id_lieu INTO lieu
FROM TBL_LIEU
WHERE est_xgs_lieu=1;
IF :NEW.dateImpr IS NOT NULL THEN
IF :NEW.preImpcode1 IS NOT NULL AND :NEW.preImpQt1>0 THEN
SELECT id_reference,POURCENTAGE_GACHE_REFERENCE INTO reference,gache
FROM TBL_REFERENCE,TBL_STOCK
WHERE code_reference_xgs=:NEW.preImpcode1
AND id_reference=fk_reference
and fk_lieu=lieu;
IF reference IS NOT NULL THEN
INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)     
VALUES(:NEW.dateMsp, ROUND(:NEW.preImpQt1*((gache/100)+1)), 'Impression', lieu, reference);
     UPDATE TBL_STOCK
     SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt1*((gache/100)+1))
WHERE fk_lieu=lieu
     AND fk_reference=reference;
     END IF;
     END IF;
IF :NEW.preImpcode2 IS NOT NULL AND :NEW.preImpQt2>0 THEN
SELECT id_reference,pourcentage_gache_reference INTO reference,gache
FROM TBL_REFERENCE,TBL_STOCK
WHERE code_reference_xgs=:NEW.preImpcode2
AND id_reference=fk_reference
and fk_lieu=lieu;
IF reference IS NOT NULL THEN
     INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
          VALUES(:NEW.dateMsp, ROUND(:NEW.preImpQt2*((gache/100)+1)), 'Impression', lieu, reference);
     UPDATE TBL_STOCK
     SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt2*((gache/100)+1))
WHERE fk_lieu=lieu
     AND fk_reference=reference;
     END IF;
     END IF;
IF :NEW.preImpcode3 IS NOT NULL AND :NEW.preImpQt3>0 THEN
SELECT id_reference,pourcentage_gache_reference INTO reference,gache
FROM TBL_REFERENCE,TBL_STOCK
WHERE code_reference_xgs=:NEW.preImpcode3
AND id_reference=fk_reference
and fk_lieu=lieu;
IF reference IS NOT NULL THEN
     INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
          VALUES(:NEW.dateMsp, ROUND(:NEW.preImpQt3*((gache/100)+1)), 'Impression', lieu, reference);
     UPDATE TBL_STOCK
     SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt3*((gache/100)+1))
WHERE fk_lieu=lieu
     AND fk_reference=reference;
     END IF;
END IF;
IF :NEW.preImpcode4 IS NOT NULL AND :NEW.preImpQt4>0 THEN
SELECT id_reference,pourcentage_gache_reference INTO reference,gache
FROM TBL_REFERENCE,TBL_STOCK
WHERE code_reference_xgs=:NEW.preImpcode4
AND id_reference=fk_reference
and fk_lieu=lieu;
IF reference IS NOT NULL THEN
     INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
          VALUES(:NEW.dateMsp,ROUND(:NEW.preImpQt4*((gache/100)+1)), 'Impression', lieu, reference);
     UPDATE TBL_STOCK
     SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt4*((gache/100)+1))
WHERE fk_lieu=lieu
     AND fk_reference=reference;
END IF;
END IF;
IF :NEW.preImpcode5 IS NOT NULL AND :NEW.preImpQt5>0 THEN
SELECT id_reference,pourcentage_gache_reference INTO reference,gache
FROM TBL_REFERENCE,TBL_STOCK
WHERE code_reference_xgs=:NEW.preImpcode5
AND id_reference=fk_reference
and fk_lieu=lieu;
IF reference IS NOT NULL THEN
     INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
          VALUES(:NEW.dateMsp, ROUND(:NEW.preImpQt5*((gache/100)+1)), 'Impression', lieu, reference);
     UPDATE TBL_STOCK
     SET nombre_volume_stock= nombre_volume_stock - ROUND(:NEW.preImpQt5*((gache/100)+1))
WHERE fk_lieu=lieu
     AND fk_reference=reference;
END IF;
IF reference IS NULL THEN
     erreur:=1;
     end if;
END IF;
END IF;
IF :NEW.dateMsp IS NOT NULL THEN
IF :NEW.encartCode1 IS NOT NULL AND :NEW.encartQt1>0 THEN
     SELECT id_reference,pourcentage_gache_reference INTO reference,gache
FROM TBL_REFERENCE
WHERE code_reference_xgs=:NEW.encartCode1;
     INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
     VALUES(:NEW.dateExp,:NEW.encartQt1,'Impression',lieu,reference);
     UPDATE TBL_STOCK
     SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt1
WHERE fk_lieu=lieu
     AND fk_reference=reference;
     END IF;
IF :NEW.encartCode2 IS NOT NULL AND :NEW.encartQt2>0 THEN
SELECT id_reference, pourcentage_gache_reference INTO reference,gache
FROM TBL_REFERENCE
WHERE code_reference_xgs=:NEW.encartCode2;
     INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)     
     VALUES(:NEW.dateExp, :NEW.encartQt2, 'Impression', lieu, reference);
     UPDATE TBL_STOCK
     SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt2
WHERE fk_lieu=lieu
     AND fk_reference=reference;
     END IF;
IF :NEW.encartCode3 IS NOT NULL AND :NEW.encartQt3>0 THEN
     SELECT id_reference , pourcentage_gache_reference INTO reference, gache
FROM TBL_REFERENCE
WHERE code_reference_xgs=:NEW.encartCode3;
     INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
     VALUES(:NEW.dateExp, :NEW.encartQt3, 'Impression', lieu, reference);
     UPDATE TBL_STOCK
     SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt3
WHERE fk_lieu=lieu
     AND fk_reference=reference;
END IF;
IF :NEW.encartCode4 IS NOT NULL AND :NEW.encartQt4>0 THEN
     SELECT id_reference , pourcentage_gache_reference INTO reference,gache
FROM TBL_REFERENCE
WHERE code_reference_xgs=:NEW.encartCode4;
     INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
     VALUES(:NEW.dateExp,:NEW.encartQt4, 'Impression', lieu, reference);
     UPDATE TBL_STOCK
     SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt4
WHERE fk_lieu=lieu
     AND fk_reference=reference;
END IF;
IF :NEW.encartCode5 IS NOT NULL AND :NEW.encartQt5>0 THEN
     SELECT id_reference,pourcentage_gache_reference INTO reference,gache
FROM TBL_REFERENCE
WHERE code_reference_xgs=:NEW.encartCode5;
     INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
          VALUES(:NEW.dateExp,:NEW.encartQt5, 'Impression', lieu, reference);
     UPDATE TBL_STOCK
     SET nombre_volume_stock= nombre_volume_stock - :NEW.encartQt5
WHERE fk_lieu=lieu
     AND fk_reference=reference;
     END IF;
IF :NEW.codeEnv IS NOT NULL and :NEW.nbPlis>0 THEN
     SELECT id_reference INTO reference
FROM TBL_REFERENCE,TBL_STOCK
WHERE code_reference_xgs=:NEW.codeEnv
AND id_reference=fk_reference
and fk_lieu=lieu;
IF reference IS NOT NULL THEN
     INSERT INTO TBL_SORTIE(date_sortie, quantite_volume_sortie, transporteur_sortie, fk_lieu, fk_reference)
     VALUES(:NEW.dateMsp, :NEW.nbPlis, 'Impression', lieu, reference);
     UPDATE TBL_STOCK
     SET nombre_volume_stock= nombre_volume_stock - :NEW.nbPlis
WHERE fk_lieu=lieu
     AND fk_reference=reference;
END IF;
END IF;
END IF;
EXCEPTION
when NO_DATA_FOUND then
v_file:= UTL_FILE.FOPEN ('DOSSIER_EXP','rejet_stock'||to_char(sysdate,'DD-MM-YYYY-hh24-mi-ss')||'.csv','A',32767);
UTL_FILE.PUT_LINE(v_file,:new.FLUXIDCLIENT||';'||:new.FLUXDATECREATION||';'||:new.NOMCLIENT||';'||:new.APPLILABEL||';'
||:new.LOTID||';'||:new.NUMEROBATCHSOUSLOT||';'||:new.FILIERE||';'||:new.DATEIMPR||';'||:new.DATEMSP||';'
||:new.DATEEXP||';'||:new.NBPAGES||';'||:new.NBPLIS||';'||:new.ISTEMPOST||';'||:new.SSLOTSTATUT||';'
||:new.NOMIMPRIMANTE||';'||:new.MODEIMPRESSION||';'||:new.ENCARTCODE1||';'||:new.ENCARTCODE2||';'||:new.ENCARTCODE3||';'
||:new.ENCARTCODE4||';'||:new.ENCARTCODE5||';'||:new.ENCARTQT1||';'||:new.ENCARTQT2||';'||:new.ENCARTQT3||';'
||:new.ENCARTQT4||';'||:new.ENCARTQT5||';'||:new.PREIMPCODE1||';'||:new.PREIMPCODE2||';'||:new.PREIMPCODE3||';'
||:new.PREIMPCODE4||';'||:new.PREIMPCODE5||';'||:new.PREIMPQT1||';'||:new.PREIMPQT2||';'||:new.PREIMPQT3||';'
||:new.PREIMPQT4||';'||:new.PREIMPQT5||';'||:new.CODEENV||';');
UTL_FILE.FFLUSH (v_file);
UTL_FILE.FCLOSE(v_file);
erreur:=1;
ROLLBACK;
end;

You can't use SAVEPOINT / ROLLBACK TO SAVEPOINT statements in the database trigger:
ORA-04092: cannot SET SAVEPOINT in a trigger
ORA-04092: cannot ROLLBACK in a trigger
I am not sure what you need exactly, but you can try this:
Simulating ROLLBACK TO SAVEPOINT Behavior in a Database Trigger
http://www.quest-pipelines.com/pipelines/plsql/tips02.htm#JUNE
Regards,
Zlatko Sirotic

Similar Messages

  • Problem with trigger and entity in JHeadsart, JBO-25019

    Hi to all,
    I am using JDeveloper 10.1.2 and developing an application using ADF Business Components and JheadStart 10.1.2.27
    I have a problem with trigger and entity in JHeadsart
    I have 3 entity and 3 views
    DsitTelephoneView based on DsitTelephone entity based on DSIT_TELEPHONE database table.
    TelUoView based on TelUo entity based on TEL_UO database table.
    NewAnnuaireView based on NewAnnuaire entity based on NEW_ANNUAIRE database view.
    I am using JHS to create :
    A JHS table-form based on DsitTelephoneView
    A JHS table based on TelUoView
    A JHS table based on NewAnnuaireView
    LIB_POSTE is a :
    DSIT_TELEPHONE column
    TEL_UO column
    NEW_ANNUAIRE column
    NEW_ANNUAIRE database view is built from DSIT_TELEPHONE database table.
    Lib_poste is an updatable attribut in TelUo entity, DsitTelephone entity, NewAnnuaire entity.
    Lib_poste is upadated in JHS table based on TelUoView
    I added a trigger on my database shema « IAN » to upadate LIB_POSTE in DSIT_TELEPHONE database table :
    CREATE OR REPLACES TRIGGER “IAN”.TEL_UO_UPDATE_LIB_POSTE
    AFTER INSERT OR UPDATE OFF lib_poste ONE IAN.TEL_UO
    FOR EACH ROW
    BEGIN
    UPDATE DSIT_TELEPHONE T
    SET t.lib_poste = :new.lib_poste
    WHERE t.id_tel = :new.id_tel;
    END;
    When I change the lib_poste with the application :
    - the lib_poste in DSIT_TELEPHONE database table is correctly updated by trigger.
    - but in JHS table-form based on DsitTelephoneView the lib_poste is not updated. If I do a quicksearch it is updated.
    - in JHS table based on NewAnnuaireView the lib_poste is not updated. if I do a quicksearch, I have an error:
    oracle.jbo.RowAlreadyDeletedException: JBO-25019: The row of entity of the key oracle.jbo. Key [null 25588] is not found in NewAnnuaire.
    25588 is the primary key off row in NEW_ANNUAIRE whose lib_poste was updated by the trigger.
    It is as if it had lost the bond with the row in the entity.
    Could you help me please ?
    Regards
    Laurent

    The following example should help.
    SQL> create sequence workorders_seq
      2  start with 1
      3  increment by 1
      4  nocycle
      5  nocache;
    Sequence created.
    SQL> create table workorders(workorder_id number,
      2  description varchar2(30),
      3   created_date date default sysdate);
    Table created.
    SQL> CREATE OR REPLACE TRIGGER TIMESTAMP_CREATED
      2  BEFORE INSERT ON workorders
      3  FOR EACH ROW
      4  BEGIN
      5  SELECT workorders_seq.nextval
      6    INTO :new.workorder_id
      7    FROM dual;
      8  END;
      9  /
    Trigger created.
    SQL> ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS';
    Session altered.
    SQL> insert into workorders(description) values('test1');
    1 row created.
    SQL> insert into workorders(description) values('test2');
    1 row created.
    SQL> select * from workorders;
    WORKORDER_ID DESCRIPTION                    CREATED_DATE
               1 test1                          30-NOV-2004 15:30:34
               2 test2                          30-NOV-2004 15:30:42
    2 rows selected.

  • Differences between trigger and Integrity Constraints

    waht are the differences between trigger and Integrity Constraints

    waht are the differences between trigger and Integrity ConstraintsConstraints are to be preferred:
    "Declarative Ease
    Define integrity constraints using SQL statements. When you define or alter a table, no additional programming is required. The SQL statements are easy to write and eliminate programming errors. Oracle controls their functionality. For these reasons, declarative integrity constraints are preferable to application code and database triggers. The declarative approach is also better than using stored procedures, because the stored procedure solution to data integrity controls data access, but integrity constraints do not eliminate the flexibility of ad hoc data access.
    Centralized Rules
    Integrity constraints are defined for tables (not an application) and are stored in the data dictionary. Any data entered by any application must adhere to the same integrity constraints associated with the table. By moving business rules from application code to centralized integrity constraints, the tables of a database are guaranteed to contain valid data, no matter which database application manipulates the information. Stored procedures cannot provide the same advantage of centralized rules stored with a table. Database triggers can provide this benefit, but the complexity of implementation is far greater than the declarative approach used for integrity constraints."
    More:
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/data_int.htm#sthref2976

  • Commit and rollback on session level

    Hi All,
    I am calling one stored procedure and I am doing some dml operation in that sp. there after I calling another sp which contain some ddl operations. if process may be fail in somewhere I wanted to rollback all dml transactions.
    So I wanted to commit and rollback on session level. Is such kind of concept available in oracle.
    Prashant.

    Prashant,
    Not sure what you are talking about.
    Commit and rollback is always on session level!!!!
    Also all DDL statements are automatically committed, and rollback in case of errors is always statement level rollback.
    So let's assume
    begin
    insert into foo...;
    update foo...;
    execute immediate 'alter table foo add (last_update date)';
    end;
    exit
    and the alter table fails:
    1 alter table is rolled back
    2 insert and updates are not rolled back.
    If the alter table succeeds
    all statements are committed and you can't roll them back anymore.
    This is why issuing DDL in stored procedures has unwanted side effects and should be conisdered pure evil.
    Sybrand Bakker
    Senior Oracle DBA
    Experts: those who did read the documentation.

  • What are the differences between trigger and constraints?

    what are the differences between trigger and constraints?

    Try the documentation, this would be a good starting point: How Oracle Enforces Data Integrity
    C.

  • Can I call a C program in trigger, and pass updated data to this program?

    Can I call a C program in Oracle trigger, and pass updated data to this program?
    Thank you

    An update trigger has access to both the old and new values. Your update trigger can call an external procedure (a C program) and pass the old and new values as parameters. For example:
    CREATE OR REPLACE TRIGGER <tname> BEFORE UPDATE OF <tab> FOR EACH ROW
    BEGIN
    pkg.proc(:old.col, :new.col);
    END;
    Where pkg.proc has been created as an external procedure.

  • BPM design for trigger based file from Oracle

    Hi
    We have one requirement as follows:
    1. We need to receive trigger file from Oracle.
    2. As soon as we recieved trigger file, it needs to activate all other 10 JDBC adapter channels.
    3. once reciever all 10 RFC channels completed, it needs to pass that trigger file.
    Please suggest design.
    Thanks
    Siva

    Hi Siva,
    1. We need to receive trigger file from Oracle.
    define a sender CC (FILE) which polls a directory every N seconds.
    The receiver of this message should be your BPM.
    2. As soon as we recieved trigger file, it needs to activate all other 10 JDBC adapter channels.
    in your BPM, trigger your 10 sender CC (JDBC). See sap help and blog to know how to trigger externally a CC. Easy to do.
    3. once reciever all 10 RFC channels completed, it needs to pass that trigger file.
    Then always in your BPM, you have to do a correlation on the 10 SQL responses (that's crazy!). Several blogs and threads on this subject.
    And after that, in BPM what do you do of these 10 SQL responses (thats' crazy!) ? do you have to merge data ?
    Welcome to the birthday of a future monster... for dev and maintenance... Sincerely simplify your flow!
    Question: do you really need to have 10 SQL? for your needs, is it not possible to create a stored procedure in database which will do the 10 SQL (with Join tables)... if yes do it, by tis way you will have only one Sender CC (JDBC) to trigger, and no correlation in a BPM. That will greatly simplify your flow.
    Regards
    Mickael

  • Best Practice to fetch SQL Server data and Insert into Oracle Tables

    Hello,
    I want to read sqlserver data everry half an hour and write into oracle tables ( in two different databases). What is the best practice for doing this?
    We do not have any database dblinks from oracle to sqlserver and vice versa.
    Any help is highly appreciable?
    Thanks

    Well, that's easy:
    use a TimerTask to do the following every half an hour:
    - open a connection to sql server
    - open two connections to the oracle databases
    - for each row you read from the sql server, do the inserts into the oracle databases
    - commit
    - close all connections

  • Difference between upgrdae and migration about oracle database

    Difference between upgrdae and migration about oracle database
    please give the comments

    Well, the question is almost philosophic...<br>
    In 9i, there is a Migration Guide whereas in 10g there is a Upgrade Guide.<br>
    Furthermore, in 9i, there is the command line startup migrate whereas in 10g that's startup upgrade.
    Somebody think upgrade when go to new release, and migration when go to new version.<br>
    Others think upgrade when new version replace database in place, and migration when new version include a move of database.<br>
    Another point of view is : upgrade is for technical, and migration for application/data.<br>
    <br>
    Well, after these explanations, your upgrade/migratation notion will not be more clear, but I think that is not very important, only a terminology game. The most important is to know what you need : new version or new release.<br>
    <br>
    Nicolas.

  • Difference between Null in c and Null in Oracle

    Hi,
    Can any one tell me the difference between NULL in C language and NULL in Oracle
    Rds,
    Naga

    > Null is some garvage value in oracle.
    Not sure what you mean.
    AFAIK and not being a C programmer myself, isn't null CHR(0) in C? I'm not sure the two concepts (SQL null and C null) have anything in common.

  • Migration MS ACCESS FORMS and Reports to Oracle (Java or Forms or Reports)

    Hello ,
    can someone tell me, how i can migrate a whole MS ACCESS 2000 mdb (with forms and Reports) to Oracle.
    I think i have first migrate the Access DB with the OMWB to Oracle and in the next Step to convert the VBA Code to JAVA or Forms9i.
    BUT Is there a tool available for Migrating VBA code like the OMWB ????

    I don't know if this is an obvious question, but do you have MS Access 2k installed on the machine you are trying to run this from? I'm assuming yes.
    If you do and there is still a problem, you should log a ticket for support who will take your mdb and help out with the issue for you.
    Many thanks
    Barry

  • Loading MS Access Table and Data into Oracle

    Hi,
    I have few tables in MS Access. I want to create same layout of tables in Oracle and want to populate data from MS Access tables to Oracle tables.
    Please let me know if there is a way by which I can create tables and load data automatically (thru some option or script)?
    I have Oracle 10g database and its clients.
    Thanks in advance,
    Rajeev.

    You can use Oracle migration workbench
    Loading MS Access Table and Data into Oracle
    It´s very easy to use and good to import
    regards,
    Felipe

  • What is the use of commit work and rollback work

    hao friends,
    what is the use of commitwork and rollback work where we can use these open sql statements .
    thanks,
    anji

    hi all
    i have written the following code in my development system to change the records of my database.
    SELECT * FROM zyikostl INTO TABLE itab.
      LOOP AT itab INTO wtab.
        tabix = sy-tabix.
        DO.
          READ TABLE itab INTO ktab WITH KEY kostl_alt = wtab-kostl_neu.
          IF sy-subrc = 0.
            wtab-kostl_neu = ktab-kostl_neu.
            MODIFY itab FROM wtab INDEX tabix.
            CONTINUE.
          ELSE.
            EXIT.
          ENDIF.
        ENDDO.
      ENDLOOP.
    MODIFY zyikostl FROM TABLE itab.
    In the development system i have only few records its working fine,but when it is been moved to test system there are 2500 records in the database so the report is taking much time(more than 5 hours )
    i sthere any solution for this ....
    thanks,
    vaasu.

  • Trying to get a Trigger and Alert to work

    So im trying to get a trigger to work with an alert and the Alert seems to be right and the trigger complies which seems right to me, however the instruction that I have in my book does not produce the same output that I get from my Update.
    Here is the deal. I am to log into sql * with a default account as well as login as "SYSTEM"
    the trigger should invoke the Alert and output a message to re-order some more product and the status should = 0 since there is no wait time. However I don't get a "Message" from the Alert and the status = 1 which indicates timeout. So if you can take a look at my code and let me know what I did wrong or how to "Connect" the two that would be great.
    Trigger I created.
    CREATE OR REPLACE TRIGGER order_replace_trg
    AFtER UPDATE OF stock on bb_product
    FOR EACH ROW
    WHEN (OLD.stock = 24 AND NEW.stock = -2)
    DECLARE
    stock NUMBER(5,1);
    idproduct NUMBER(2);
    lv_msg_txt VARCHAR2(25);
    lv_status_num NUMBER(1);
    reorder NUMBER(3);
    BEGIN
    IF stock <> 24 AND reorder = 25 THEN
    lv_msg_txt := 'Product 4 Reorder Time!';
    DBMS_OUTPUT.PUT_LINE(lv_msg_txt);
    ELSE
    lv_status_num := 0;
    DBMS_OUTPUT.PUT_LINE(lv_status_num);
    END IF;
    END;
    The Alert:
    BEGIN
    DBMS_ALERT.REGISTER('reorder');
    END;
    DECLARE
    lv_msg_txt VARCHAR2(25);
    lv_status_num NUMBER(1);
    BEGIN
    DBMS_ALERT.WAITONE('reorder', lv_msg_txt, lv_status_num, 120);
    DBMS_OUTPUT.PUT_LINE('Alert: ' ||lv_msg_txt);
    DBMS_OUTPUT.PUT_LINE('Status: ' ||lv_status_num);
    END;
    Here is the block I need to run to test the trigger and alert.
    UPDATE bb_product
    SET stock = stock -2
    WHERE idproduct = 4;
    COMMIT;
    The message I should get is:
    Alert: Product 4 Reorder Time!
    Status: 0
    PL/SQL procedure successfully completed.
    This is what I get.
    SQL> /
    Alert:
    Status: 1
    PL/SQL procedure successfully completed.
    Thanks for your help!
    Mac

    Right. Register says "I'm interested in getting alerted to some particular event", Waitone says "I'm waiting until some event happens". Signal is the key thing that indicates that a particular event happened.
    As for your trigger, a couple of issues
    - I don't know why you're calling DBMS_OUTPUT. I'm guessing that you probably want to send a message along with your alert that the receiver gets and displays, not that you want to print a message to the window from inside the trigger.
    - You're using the local variables stock and reorder in your IF statement but you never initialize them. I'm guessing that you would want to eliminate those local variables and just use :new.stock and :new.reorder (assuming that REORDER is a column in the table).
    - Your WHEN clause doesn't seem to make sense. It's telling the trigger to fire only if you update stock from 24 to -2, which doesn't make sense. I'm not sure you would even need a WHEN clause here.
    Justin

  • How can I detect an external trigger and then generate an event or occurance

    I have a PXIe-1065 chassis with a PXIe8030 controller, PXI-6653 timing module, PXI-6542 Digital IO, and PXI-6259 DAQ board, running LabView 8.5. I need to detect a trigger (100 ns TTL pulse) from an external device then start a process on a GPIB device. Is there a way for me to detect this trigger and then generate an event, or an occurance ? Can I do this without polling a device? Can any of this hardware generate an interrupt that LabView can detect?

    My screenshot was only an example how you can approach the issue. I wasnt saying that you should try it with AI....
    Just take a closer look into the DAQmx Events and you will discover something like this:
    hope this helps,
    NorbertMessage Edited by Norbert B on 10-05-2007 02:35 AM
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.
    Attachments:
    DAQmxEvent.PNG ‏11 KB

Maybe you are looking for

  • CRACKING and PoPping in Music?! HELP!!

    What is going on with this?I spend over $300.00 on I pod by the 2 year warranty and still nada! It is not only cd downloads but purchses from the I Tunes store. I have tried tinkering with the settings in Quicktime and it still sounds like fireworks

  • BEx Query- Making into Zero value in the blank row/column

    Hi All, I am running a query on multiprovider, say I have three characteristics (sales org, distribution, customer) & key figure (amount) in the layout. I am lookling the actual & plan data in the report.  If there is no plan data for the above combi

  • How to get Adobe Flash 10 to work on IE8 on Windows Vista?

    I've tried downloading the newest Adobe Flash Player 10 on IE8 on my Windows Vista and it's not working.  It downloads but when I go back to hulu.com it says I still have to download the latest version. I've tried unistalling and installing it (sever

  • LOST ALL PHOTOS

    Hello, I switched on my mac today and opened Aperture, and every single photo one was not there. I have zero photos in my Library. The file size of my Library is 6mb. I updated to 3.1 two days ago but Aperture has been working fine since the upgrade.

  • Photoshop to Illustrator help!

    Hello all: Having an issue dragging artwork straight from Photoshop into Illustratror.  I am currently running CS4 for both. The issue is, I need to drag a layer from Photoshop to Illustrator to convert into vector form.  The problem is, whenever I d