Processing Triggers - part 2

Hello,
I would like to solve the following problem using triggers:
I need to change the DeptNo for all Emps working for Dept 20 to 50;
Trigger (or triggers) has to create Deptno 50 and copy the data from DeptName (dname) and DeptLocation (loc) to new row Where DeptNo is 50;
After that, the old DeptNo 20 has to be deleted from Dept.
The following triggers works fine:
-- step 1 --
Create or Replace Trigger TrigEmp
Before Insert or Update On Emp
For each row
Begin
INSERT INTO dept(deptno)
SELECT :NEW.deptno
FROM dual
WHERE NOT EXISTS (SELECT NULL
FROM dept
WHERE deptno = :NEW.deptno);
End;
-- step 2 --
Create or Replace Trigger TrigDept
Before Insert or Update of Deptno On Dept
For each row When(new.Deptno=50)
Begin
:New.dname := 'Sunshine';
:New.loc := 'Hawaii';
End;
The problem I have with step 3 because I have to perform DML (Delete) operation on Dept withing a trigger and I get "Mutating" error again...))
Is there any way to solve it?
Thank you for your consideration
P.S. I am still using 9i

I found the solution anyway!
Here is the code:
Create or Replace Trigger TrigEmp
Before Insert or Update On Emp
For each row
Begin
INSERT INTO dept(deptno)
SELECT :NEW.deptno
FROM dual
WHERE NOT EXISTS (SELECT NULL
FROM dept
WHERE deptno = :NEW.deptno);
End;
Create or Replace Trigger TrigDept
Before Insert or Update of Deptno On Dept
For each row When(new.Deptno=50)
Begin
:New.dname := 'Sunshine';
:New.loc := 'Hawaii';
End;
Create or replace Procedure delete_dept
(Message in varchar2) is
BEGIN
DBMS_OUTPUT.PUT_LINE(Message);
END;
Create or replace trigger TrigDept2
After insert or update of DeptNo on Dept
For each row When(new.Deptno=50)
Begin
delete_dept(' ! Message for DBA - All data copied into new Dept - Deptno 20 deleted !');
End;
Create or replace trigger TrigDept3
After insert or update on Emp
For each row When(old.Deptno=20)
Begin
delete from dept
where deptno=20;
End;
runs fine and tables are not mutating anymore...!!
the idea was only to learn how to create triggers, nothing more...
I know how to create triggers using form builder in developer suite but it is always nice to understand what processes run under when you press buttons...))
thank you for help...

Similar Messages

  • Xellerate USR Process Triggers 11g

    By default in OIM 11g, process triggers do not fire as the setting of XLUserResource.ProvisionMode is set to DB.
    In an earlier discussion thread about "some issues in OIM password generation", it was stated that it is not recommended to change the setting to "JAVA" which re-enables the process triggers.
    Why would I not want to change the setting back to "JAVA"?
    Thanks.

    In 11g, Recon is stored procedure based.
    If you change it to Java then it won't utilize new feature of OIM 11g so performance will be down.

  • Process triggering wrong time ( Urgent ! )

    We created a process and we want to trigger it when a button process.
    Process Name : PROCESS_CREATE_ORDER
    Button Name : P_CREATE_ORDER
    In Conditional Processing part of PROCESS_CREATE_ORDER
    When Button Pressed (Process After Submit When this Button is Pressed) attiribute set P_CREATE_ORDER button.
    But process is triggering every time page submitted.
    So it cause errors.
    we are using HTMLDB 1.6 version.

    Ali,
    Just taking a quick look at one of my pages, I have many pages that do similar things, where I have a button to perform a process, but a conditional process (depends on which button is preesed).
    On the process page, I also specify under the "Conditional Computations", the "Condition Type" - "Request = Expression1", and then then under the "Expression1" field, I specify the button name (in your case it would be "P_CREATE_ORDER" (no quotes).
    Right off hand, that's about all I can think of, other than trying to create another process that does nothing. It seems like your process is not conditional to be executing every time the page is submitted.
    Bill Ferguson

  • Process triggered before update table filled

    Hello,
    We have a program that
    - calls one FM (RSSM_SDL_INFOPACKAGE_DIALOG) that gives direct access to a specific infopackage (via program parameters) that is uploading an ODS when executed
    - secondly calls another FM (BP_EVENT_RAISE) that triggers an event that activates the ODS (and some other processes afterwards).
    The problem is: The event is triggered when the infopackage is left - and the infopackage might be left before the update table is filled. So the activating process might start before the filling of the update table has been done (monitor status not green).
    How can this issue be solved keeping in mind that the end-user should only execute one transaction (the one that's execute the program).
    Kind regards,
    Johnny

    Hi Simon,
    Can you provide me with information of how to build in this loop. Please check the relevant part of our program:
      CALL FUNCTION 'RSSM_SDL_INFOPACKAGE_DIALOG'
        EXPORTING
          SOURCE.......
    IMPORTING
    EXCEPTIONS
       error                  = 1
       OTHERS                 = 2.
      IF sy-subrc <> 0.
      PERFORM log_nogo.
        MESSAGE e001(00) WITH 'FM Error: Infopackage error message succesfully logged'.
      ELSE.
        IF NOT p_evtid IS INITIAL.
          PERFORM raise_event
               USING p_evtid
            CHANGING ret_code.
          IF ret_code <> 0.
            MESSAGE e002(zbps) WITH 'Error raising event '
                                   p_evtid.
          ELSE.
            MESSAGE s002(zbps) WITH 'Event'
                                  p_evtid
                                  ' successfully' ' raised'.
          ENDIF.
        ENDIF.
      ENDIF.
    Thanks,
    Johnny

  • BPM Process triggered externally

    I have created a BPM process and I am able to test it from NWA -> Process repository. But When I am testing from WS Navigator then I am getting an error like-> Web Service returned an error. Fault Code: "(http://schemas.xmlsoap.org/soap/envelope/)Server" Fault String: "Process start has been triggered."
    But my process is started fine. Actualy I want to access this WSDL URL from other applications. Can anybody help me?
    Thanks,
    Somnath

    Hi Somnath,
                       u will get the fault message , when u test the services in ws navigator for trigerring the BPM Process. check this article for Starting the BPM process
    [http://help.sap.com/saphelp_nwce711/helpdata/en/59/b2af840e67514f8e8973d97d494c9b/content.htm]
    Hope it helps
    Thanks and regards

  • Process Triggers for USR_PASSWORD

    Hi All,
    I have wriiten a custom code to update a field when the user password in OIM is changed. I have created an Xellerate User Process Task and mapped it as decode against "USR_PASSWORD" in the lookup table - Lookup.USR_PROCESS_TRIGGERS.
    Also, I have set the system property(Xellerate User resource provision mode) value from "DB" to "JAVA".
    When XELSYSADM changes the password of the user, the process task is triggered. But when the user tries to change his password, the code doesnot trigger.
    Please let me know how to achive this.

    What does your task on the Xellerate User do? Also, what does your log say when the end user resets their password? I wonder if there is a permission issue preventing the task for running.
    If you are just propagating the password, i suggest you put the task on your resource instances, and not the xellerate user.
    Another option you have is to create a PostProcessor Event Handler on the user. Just put an if statement to see if the orchestration parameters contain "usr_password" and the operation is modify. Then put your code here to perform your tasks.
    -Kevin

  • I am unable to update my iPhone from ios4 to ios7, I know you have to do this via the computer however the backing up process stops part way through and it is unable to carry on

    I have ios4 on my iPhone 4 and I have tried to update it to ios7 and to do this I know you have do use the computer. however part of the way through, the back up process stops and nothing else happens

    I would suggest that you tru and update through iTunes on your computer. Also, could you connect your computer up to the internet using a wired connection rather than wireless - this will be faster and more reliable, particularly when you need to download a large file.
    Then try your update. This time, in iTunes, why not try to get it to download the sofware first (Download Only). You can then appy it to your iPhone later, once it has downloaded.

  • Which Process triggered a workflow

    Hi,
    New to WF so any help would be appreciated.
    I have a standard Oracle workflow which I need to adapt, the main logic will be to create a split decision based on which process actually called the Workflow.
    How do I know which process called the workflow?
    Thanks
    Scott

    Please ignore the above as the problem is not actually what I originally thought was happening. It turns out that any file which is updated through Oracle Drive does not trigger the BPEL workflow for the Upload Document workflow operation. The workflow that was being triggered for which I could not get details for was a temp file that was being created when browsing Oracle Drive before overwriting a file, the workflow could not get the temp files document details as the file was deleted before it could do so. Does anyone know a way of getting the workflow to be triggered upon the update of a file in Oracle Drive?
    Many Thanks
    Dave

  • OIM 11g R1: Usr Process Triggers Not Working on Concurrent Calls

    Version: 11.1.1.5.7
    I am making two API calls to change a user's password.
    The first call uses the ADMIN to generates a random password for a user.
    The second call uses the user to change his/her own password.
    I am getting an issue where one of the calls does not kickoff the Usr Process Trigger.
    This happens like 1 in 15 tries.
    Is this a bug or am i missing sometime?
    Given below is the test code.
    import java.util.Hashtable;
    import java.util.Random;
    import java.util.logging.Logger;
    import oracle.core.ojdl.logging.ODLLogger;
    import oracle.iam.identity.usermgmt.api.UserManager;
    import oracle.iam.platform.OIMClient;
    import oracle.iam.selfservice.self.selfmgmt.api.AuthenticatedSelfService;
    public class Test
        public static final Logger logger = ODLLogger.getLogger(Test.class.getName());
        public static void main(String args[]) throws Exception
            String authwlConfigPath = "/home/oracle/Oracle/Middleware/Oracle_IDM1/designconsole/config/authwl.conf";
            System.setProperty("java.security.auth.login.config", authwlConfigPath);
            String ctxFactory = "weblogic.jndi.WLInitialContextFactory";
            String serverURL = "t3://localhost:14000";
            Hashtable env = new Hashtable();
            env.put(OIMClient.JAVA_NAMING_PROVIDER_URL, serverURL);
            env.put(OIMClient.JAVA_NAMING_FACTORY_INITIAL, ctxFactory);
            OIMClient oimClient = new OIMClient(env);
            OIMClient userOimClient = new OIMClient(env);
            //Admin changes User Password
            oimClient.login("xelsysadm", "Password1".toCharArray());
            UserManager usrMgrOps = oimClient.getService(UserManager.class);
            String generatedPassword = "a" + generateRandomUserPassword(30);
            System.out.println("Generated Password: " + generatedPassword);
            usrMgrOps.changePassword("tstark", generatedPassword.toCharArray(), true);
            //User changes their own Password
            userOimClient.login("tstark", generatedPassword.toCharArray());
            String myPassword = "Password20";
            AuthenticatedSelfService authOps = userOimClient.getService(AuthenticatedSelfService.class);
            authOps.changePassword(generatedPassword.toCharArray(), myPassword.toCharArray() , myPassword.toCharArray());
            System.out.println("My Password: " + myPassword);
            oimClient.logout();
            userOimClient.logout();
        public static String generateRandomUserPassword(int length){
            if(length < 1)
                throw new IllegalArgumentException("length < 1: " + length);
            char[] characters = new char[62];
            char[] randomUserPassword = new char[length];
            Random random = new Random();
            for (int i = 0; i < 10; ++i)
                  characters[i] = (char) ('0' + i);
            for (int i = 10; i < 36; ++i)
              characters[i] = (char) ('a' + i - 10);
            for (int i = 36; i < 62; ++i)
              characters[i] = (char) ('A' + i - 36);
            for (int i = 0; i < randomUserPassword.length; ++i)
                randomUserPassword[i] = characters[random.nextInt(characters.length)];
            return new String(randomUserPassword);

    Set the "Off-line" flag to true in your "Change User Password" process task.

  • Process triggered by file upload - is GP the right tool?

    Hello All,
    I have a process I need to model that starts with a file upload from the user, followed by some manipulation of the file by some web services.
    Is GP the right tool for modeling that process?
    After completing the file upload action, how can I access the the uploaded file on the server?
    Do I need to implement the file upload handling with Webdynpor?
    Thanks!
    Yossi

    Yossin,
    Based on your requirement, the GP process would be to use File Input CO followed by Web Service CO (in that order). Consolidate the output param of File Input CO (which is the File Structure) to the input for the Web Service CO (which is also a structure). I dont think you need to save the file to the local drive. The web service should be able to consume the uploaded file (which resides in the process context).
    Thanx,
    Mahesh

  • Make-to-order production (assembly processing) - Missing Parts

    Hi Guys
    During creating an assembly order, availability check comes up with missing parts.
    Can someone tell me how to proceed from here? I checked the material master fro the missing part and in MRP2, procrement type = x.
    What are my options, can i save this order even though i have missing parts? How do i carry on?
    Thanks
    Ahmad Yahya

    Hi,
    relevant material master setting is in MRP3, availability check. If you would like to skip the check, set the indicator to KP - no check.
    Best regards,
    Zuzana

  • Processing multi-part messages in Flex

    Hello,
    I'm writing an extension for Photoshop using AS3 and Flex. This extension connects to a HTTP server that replies with an HTTP multi-part response containing images. Is Flex able to decode this response?
    So far I have only been able to see the response as a whole text, but not interact with it without parsing it manually. Is there any other option?
    Thanks a lot,

    There is a property file that contains all default messages. The value is required message takes a parameter � element id.
    You have three ways of handling this:
    1.     If you are using JSF 1.2, in the <h:form> tag use property prependId=�false�. This will stop JSF from generating the long element ids.
    2.     Again, if you are using JSF 1.2, you may use the new property requiredMessage of the <h:inputText> tag.
    3.     Another solution, but not a very good one, is to change the text of the error message as it is defined in the properties file. But this will change the error message text everywhere.

  • Prevent process triggers from executing based on a specific condition.

    We are using OIM 9.1 and have a rather odd problem. We have PSFT HR as our trusted source with AD and Exchange as two of our target systems.
    The sAMAccountName in AD is generated based on a combination of the last name and first name of the user. Also french characters in the name are converted to english characters before the sAMAccountName is generated. For example è would be converted to e.
    When someone gets married and changes their last name it is updated in OIM and thus the sAMAccountName changes also. The last name change is made in the OIM webapp and then all of the process tasks run based on the Lookup.USR_PROCESS_TRIGGERS lookup table. i.e. when USR_LAST_NAME changes then there are several process tasks that run for both AD and Exchange.
    What I need to be able to do is when the sAMAccountName is the same before and after the change (remember that french characters are converted) I don't want the process tasks to run. Here's a scenario:
    1. User is provision with a sAMAccountName "berube" - notice that there are no accents in the name
    2. User last name is changed to "bèrubè" - notice the accents
    After running both names through our conversion (a Java method) they are both the same "berube = berube (converted french characters)". If this situation occures then I don't want the process tasks associated with the USR_LAST_NAME change to run. Is there a way to do this?
    Another way of stating this is "Can I make the process tasks listed in the Lookup.USR_PROCESS_TRIGGERS table conditional?"
    Thanks in advance for your help.

    If you don't want something to run when the value is the same, i suggest you always update the process form containing the values, and then let the Updated task run to update in the target. If your value is the same twice, and you try to update the field with the same value twice, it would only trigger the first time because there won't be a change on the second.
    -Kevin

  • Strating a process triggered by db table content change

    Hi all
    I am new to BPM.
    I am trying to understand if BPM answers our requirements.
    Is there a possibility to start a process when a field from data base table changes?
    Thanks,
    Nitsan

    Hi,
    Yes It can be acheived Check this [document|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/80ddeba4-e780-2b10-7bb2-fc7a33efabbd]
    also search with keyword Change Document in SCN lot of discussions are available...
    Regards
    Pavan

  • Processing Triggers

    Hello
    I have to create a Trigger that would insert a new Deptno into a table Dept before insert or update on Emp When Deptno is not found!!
    The question is:
    I can not find a syntax for "not found"
    The code should be as follows:
    Create or Replace trigger TriggerDept
    Before Insert or Update On Emp
    For each row
    When (I think here I have to insert something like "new.Deptno != found")
    Begin
    Insert Into Dept(Deptno, Loc) Values(50, 'LA');
    Update Emp
    Set Sal = Sal*1.015
    Where Deptno = 50;
    End;
    So this "new.Deptno not found" is not correct
    What is a right syntax for that? And the right place to use it??
    Thank you

    Sloger wrote:
    department name 50, location 'LA'
    So you want ANY non-existing department to have name 50, location 'LA'? Does not make much sense, does it? Anyway:
    CREATE OR REPLACE
      TRIGGER EMP_BIR
      BEFORE INSERT
      ON EMP
      FOR EACH ROW
      BEGIN
          MERGE
            INTO dept d1
            USING (SELECT :new.deptno deptno,'50' dname,'LA' location FROM dual) d2
            ON (d1.deptno = d2.deptno)
            WHEN NOT MATCHED THEN INSERT VALUES(d2.deptno,d2.dname,d2.location);
    END;
    / For example:
    SQL> DROP TABLE EMP1
      2  /
    Table dropped.
    SQL> DROP TABLE DEPT1
      2  /
    Table dropped.
    SQL> CREATE TABLE EMP1 AS SELECT * FROM EMP
      2  /
    Table created.
    SQL> CREATE TABLE DEPT1 AS SELECT * FROM DEPT
      2  /
    Table created.
    SQL> ALTER TABLE DEPT1
      2    ADD CONSTRAINT DEPT1_PK
      3    PRIMARY KEY(DEPTNO)
      4  /
    Table altered.
    SQL> ALTER TABLE EMP1
      2    ADD CONSTRAINT EMP1_FK1
      3    FOREIGN KEY(DEPTNO)
      4    REFERENCES DEPT1(DEPTNO)
      5  /
    Table altered.
    SQL> CREATE OR REPLACE
      2    TRIGGER EMP1_BIR
      3    BEFORE INSERT
      4    ON EMP1
      5    FOR EACH ROW
      6    BEGIN
      7        MERGE
      8          INTO dept1 d1
      9          USING (SELECT :new.deptno deptno,'50' dname,'LA' location FROM dual) d2
    10          ON (d1.deptno = d2.deptno)
    11          WHEN NOT MATCHED THEN INSERT VALUES(d2.deptno,d2.dname,d2.location);
    12  END;
    13  /
    Trigger created.
    SQL> INSERT INTO EMP1(DEPTNO) VALUES(99)
      2  /
    1 row created.
    SQL> SELECT  *
      2    FROM  DEPT1
      3  /
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
            99 50             LA
    SQL> SELECT  DEPTNO
      2    FROM  EMP1
      3  /
        DEPTNO
            20
            30
            30
            20
            30
            30
            10
            20
            10
            30
            20
        DEPTNO
            30
            20
            10
            99
    15 rows selected.
    SQL> SY.

Maybe you are looking for