Trigger setting value when updating

I need to have a row-level trigger set a value only when an update parameter is not specified in the query. The following trigger doesn't work as expected in SQL Developer - :new.prj_sync_modified_by seems to be the prior value in the row. I need to have :new.prj_sync_modified_by set to 0 whever an update does not specify a value for the prj_sync_modified_by column.
CREATE OR REPLACE TRIGGER "MQSR"."TR_PROJECT_IU"
before insert or update
on PROJECT
referencing old as old new as new
for each row
begin
if inserting then
:new.prj_sync_created_dt := sysdate;
if :new.prj_sync_created_by is null then
:new.prj_sync_created_by := 0;
end if;
end if;
:new.prj_sync_modified_dt := sysdate;
if :new.prj_sync_modified_by is null then
:new.prj_sync_modified_by := 0;
end if;
end TR_PROJECT_IU;
ALTER TRIGGER "MQSR"."TR_PROJECT_IU" ENABLE;
Thanks in advance,
Dave

Thanks. I found the right syntax for the update part:
if not updating('prj_sync_modified_by') then
:new.prj_sync_modified_by := 0;
end if;
I need to overwrite the prior prj_sync_modified_by value with 0 if no value is specified (not just at row initialization). Between setting a column default and the above (for inserts), I think I'm set.
Message was edited by:
user625389

Similar Messages

  • "Use condition indicators" and "Print setting" errors when updating FM book

    I recently updated the designs of some templates used in our FM books. I created a sample manual using the new templates to test it out. When updating the book, I get the following errors. I have fixed errors before, but I've never seen these ones.

    Hi priya,
    Not sure: check syntax in your Update Roules, also at level of start routine.
    Ciao.
    Riccardo.

  • A wierd date value when updating table

    Hi all,
    This looks totally strange to me. I have a table that has a column of type 'Date'. DataBase is Oracle 10g/11g.
    In the Java code, the query looks like this:
    "update mytable set Time_stamp = to_date(?,'yyyy-mm-dd hh24:mi:ss') "...
    stmt.setString(1, "2010-12-06 17:17:08");
    When checking the table after this update, it shows '12/6/2010 5:17:08 AM'
    Please notice the '*AM*'. Why did this happen?
    Thanks!
    Shawn

    Hi,
    1) Check Tools-> Preferences -> Database -> NLS for Jdeveloper settings.
    2) To check the date format in DB:
    ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY MM DD';
    select sysdate from dual;
    ALTER SESSION SET NLS_DATE_FORMAT = 'HH24:MI:SS';
    select sysdate from dual;
    As long the value passed to the DB column is in the same data-type, you don't have to worry about the date value. Just use appropriate format mask while showing in the UI.
    Thanks,
    Harikiran

  • Inbound idoc values when updated from user exit not saved

    I'm trying to process some user exits of an inbound idoc from WE19.
    The values get correctly populated to IDOC_DATA internal tables of IDOC_INPUT_ORDRSP function module in debug kode
    but when the new idoc is generated from WE19 , those segment values (populated by exit) are not shown/saved.
    The user exit is EXIT_SAPLEINM_007.
    Is it not possible to populate segment values of inbound idocs from using user exits. If yes , then during testing using WE19 , every time a new idoc is created it should display those values into the concerned segments. Please help.

    Hello,
    yes is possible it ...
    I think the problem is:
    or
    you have something wrong when to append the new line on internal table
    or
    the exit used is not correct: read the documentation on EXIT_SAPLEINM_0**

  • Set value when a virtual, analog modem should answers in Server 2012 Routing and Remote Access

    Hi there,
    I googled for hours on the following problem:
    We have a Routing and Remote Access Server with an Dialogic Diva PRI card (30 lines). The card provides an analog, virtual modem pool. All this runs on Windows Server 2012 (without R2).
    My problem is that the client will be connected after 3 or 4 rings on the line (I can not hear properly with our client device), but it should be connected after the first ring.
    Under Server 2000 there was the possibility to set the value "NumberOfRings" in the registry and / or  set the modem to ATS0 = 1. Both ways do not work in Server 2012.
    Can anyone tell me how it works under 2012?
    Thanks and regards
    Andre

    I assume you followed Dialogic's instructions for configuring the device on Windows Server 2012.  It would most likely make more sense to contact Dialogic if you are having issues.  They support the product.  If it is not working according
    to their configuration instructions, they are in the best position to be able to answer your questions.
    . : | : . : | : . tim

  • FndLoad updates wrong value set values

    Hello.
    When uploading value set values, fndload updates both US and N language value descriptions. Supposed is to update only N language values.
    Step by step what I have done.
    *1. Set NLS_LANG environment variable*
    export NLS_LANG=NORWEGIAN_NORWAY.WE8MSWIN1252
    *2. Downloaded value set*
    $ FNDLOAD apps/apps O Y DOWNLOAD $FND_TOP/patch/115/import/afffload.lct KONTO.ldt VALUE_SET FLEX_VALUE_SET_NAME="KONTO"
    *3. Change environment*
    *4. Set NLS_LANG environment variable*
    export NLS_LANG=NORWEGIAN_NORWAY.WE8MSWIN1252
    *5. Uploaded value set*
    $ FNDLOAD apps/apps O Y UPLOAD $FND_TOP/patch/115/import/afffload.lct KONTO.ldt
    I have investigated that its happening because of the update statement which is called by the fndload control file. Procedure fnd_flex_values_pkg.load_row line 708:
    update FND_FLEX_VALUES_TL set
    FLEX_VALUE_MEANING = X_FLEX_VALUE_MEANING,
    DESCRIPTION = X_DESCRIPTION,
    LAST_UPDATE_DATE = X_LAST_UPDATE_DATE,
    LAST_UPDATED_BY = X_LAST_UPDATED_BY,
    LAST_UPDATE_LOGIN = X_LAST_UPDATE_LOGIN,
    SOURCE_LANG = userenv('LANG')
    where FLEX_VALUE_ID = X_FLEX_VALUE_ID
    and userenv('LANG') in (LANGUAGE, SOURCE_LANG);
    Problem is with this statement and userenv('LANG') in (LANGUAGE, SOURCE_LANG);, because there is included SOURCE_LANG which not always is the same as LANGUAGE. Therefore the update statement updates also US language values which source language is N
    Any suggestions how to override this problem?
    Thanks in advance!
    Aldis

    Hi Hussein,
    Thanks for the tip, but it is the same if I set the NLS_LANG environment variable *"export NLS_LANG=NORWEGIAN_NORWAY.WE8MSWIN1252"* before upload.
    I will try a workaround. Update the source_lang so it is the same as language and then upload with fndload.
    Aldis
    Edited by: user1579859 on 2010.8.3 00:49

  • Why is this table trigger not firing when insert/update from servlet?

    Hi!
    I have this servlet that parses XML and stores values into Oracle tables. I have created a table trigger so that when one table is updated, a trigger is fired and the current system date is store in another table's field.
    I have tested the trigger in Toad and it works, that is, if I update the table that the trigger is set to, the SYSDATE is stored as intended.
    Here is the trigger's code:
    DECLARE
    tmpVar NUMBER;
    NAME: transaction_time
    PURPOSE:
    REVISIONS:
    Ver Date Author Description
    1.0 9/14/2007 1. Created this trigger.
    NOTES:
    Automatically available Auto Replace Keywords:
    Object Name: transaction_time
    Sysdate: 9/14/2007
    Date and Time: 9/14/2007, 8:00:42 AM, and 9/14/2007 8:00:42 AM
    Username: (set in TOAD Options, Proc Templates)
    Table Name: MS_RESLIMITS (set in the "New PL/SQL Object" dialog)
    Trigger Options: (set in the "New PL/SQL Object" dialog)
    BEGIN
    tmpVar := 0;
    UPDATE MS_Misc SET mi_lastrun = SYSDATE;
    EXCEPTION
    WHEN OTHERS THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END transaction_time;
    Now, when the table is updated by the servlet, the trigger does not fire. And here is the code from the servlet:
    --- <start of code> ---
    boolean recordExists =
    this.isRecordPresent("MS_ResLimits", "rl_compcode",
    compCode, url);
    Connection rlConn = null;
    try {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    rlConn = DriverManager.getConnection(url, dbUser,
    dbPwd);
    Statement stmt = rlConn.createStatement();
    PreparedStatement xmlUpdate = null;
    if (recordExists) {
    xmlUpdate =
    rlConn.prepareStatement("UPDATE MS_ResLimits SET rl_compcode = ?, rl_maxreslimit= ? WHERE rl_compcode =?");
    xmlUpdate.setString(1, compCode);
    xmlUpdate.setString(2, maximumReservationDate);
    xmlUpdate.setString(3, compCode);
    } else {
    xmlUpdate =
    rlConn.prepareStatement("INSERT INTO MS_ResLimits VALUES(?,?)");
    xmlUpdate.setString(1, compCode);
    xmlUpdate.setString(2, maximumReservationDate);
    } //end-if-else
    int n = xmlUpdate.executeUpdate();
    rlConn.commit();
    } catch (Exception ex) {
    out.println(ex.toString() +
    "-> error inserting Max Reservation Date<br>");
    } finally {
    if (rlConn != null) {
    rlConn.close();
    } //end-try-catch-finally
    --- <end of code> ---
    What causes the trigger to fire? the commit? My understanding is that executeUpdates are in autocommit mode by default, or am I mistaken? Do I have to programmatically send something to the DB so that the trigger fires?
    BTW, I'm using JDeveloper 10.1.3.3.0. The project is being compiled with Java 1.5.0_06. The servlet is running in OCJ4 standalone. DB is 10g (don't know the release version).
    ...and, for some reason this message is not keeping format from my edit window to the post...
    Thx!
    Message was edited by:
    delphosbean
    Message was edited by:
    delphosbean
    Message was edited by:
    delphosbean

    You are supposed to be able to preserve you formatting using the <pre></pre> tags but I can't get this to work either<br>
    <br>
    Patrick.

  • What's the exact trigger for when updating/inserting/deleting data from one DB to another DB which contains same info?

    Hi guys,
    I have created a copy of the AdventureWorks2012 DB called AdventureWorks2012_new on the same instance.
    I have created the following trigger below but my friend who is a DBA told me that this is not correct and I should be using the inserted table when creating this trigger. I would like AdventureWorks2012_new DB to be updating/inserting/deleting data from
    the same tables that have been updated/inserted/deleted in the AdventureWorks2012 DB. How exactly should I do this for all the tables in the whole database ? What I have written below is just for one of the tables, is there a quicker way to do it for all tables
    in this DB so that it performs the actions mentioned above, automatically ? Help would be greatly appreciated so I can understand how this works, thanks
    CREATE TRIGGER [HumanResources].[tr_HumanResources_AfterUpdate]
    ON [AdventureWorks2012].[HumanResources].[Department]
    AFTER UPDATE
    AS
    BEGIN
    SET NOCOUNT ON;
    UPDATE AdventureWorks2012_new.HumanResources.Department
    SET Name = t2.Name,
    GroupName = t2.GroupName,
    ModifiedDate = t2.ModifiedDate
    FROM AdventureWorks2012.HumanResources.Department AS t2
    INNER JOIN AdventureWorks2012_new.HumanResources.Department AS t1
    ON t2.DepartmentID = t1.DepartmentID
    END

    For insert it's easy:
    CREATE TRIGGER [HumanResources].[tr_HumanResources_AfterInsert]
    ON [AdventureWorks2012].[HumanResources].[Department]
    AFTER INSERT
    AS
    BEGIN
    SET NOCOUNT ON;
    Insert INTO AdventureWorks2012_new.HumanResources.Department
    (DepartmentID, Name, GroupName, ModifiedDate)
    SELECT DepartmentID, Name, GroupName, ModifiedDate
    FROM Inserted;
    END
    I didn't verify column names, so you may need to make sure to use correct column names for that table.
    Setting replication is a bit advanced topic although BOL is clear and you may start here
    http://technet.microsoft.com/en-us/library/ms151198.aspx
    If it will be complicated for you, you can ask extra questions in the MSDN Replication forum.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Graph does not autoscale when it's value is updated in a subvi and Defer Panel Updates is on

    Hello,
    I have a main VI containing several xy grpahs, which I update from a sub vi. In order to cut down on front panel redraws I defer panel updates while the graph values are updated and then redraw the FP after this has been done. However when I do this the graphs do not autoscale properly. I've attached two vi's as an example. Run the Main vi, if the Defer Panel Updates boolean is false then everything works fine, if it is true then the graph does not autoscale.
    I have found a previous post that mentions something similar (here). Has this been fixed or is there a work around.
    I'm using LV 8.5
    Thanks
    David
    Attachments:
    Main3.vi ‏22 KB
    Sub1.vi ‏14 KB

    Hi Matthew,
    Thanks for your reply, it fixed the problem. However it has thrown up a different but related issue.
    In my application the user can select how many graphs to display and I
    programmatically calculate the size and position of each graph. If any
    of the graphs overlap, even slightly, and defer panel updates is on
    then only the topmost graph autoscales correctly, the others don't at
    all, although the data they display gets updated. Turning autoscale off
    and on again for a particular graph rescales that graph, presumably
    because it has been forced to.
    I have attached a test case with 4 graphs. The size and position of the
    graphs are set by the 'Offsets' cluster. Click 'Rearrange' to get it to
    recalcute the positions. If you change the Vertical Gap or Horizontal
    Gap values to 0 or negative then the graphs will overlap. With Defer
    Panel Updates off there is no problem. With it on only the topmost
    graph updates properly.
    My current workaround is to ensure the graphs don't overlap, but I'm guessing they shouldn't be doing this anyway.
    David
    Attachments:
    PositionsCalculator.vi ‏19 KB
    Main21.vi ‏50 KB
    Plot.vi ‏22 KB

  • My ITunes got corrupted and I kept getting a message when updating iTunes64msi missing so I uninstalled all files and I thought I removed all registry values but  when reinstalling I get an older version is installed and cannot be removed. I need a soluti

    My ITunes got corrupted and I kept getting a message when updating iTunes64msi missing so I uninstalled all files and I thought I removed all registry values but  when reinstalling I get an older version is installed and cannot be removed. I need a solution.

    (1) Download the Windows Installer CleanUp utility installer file (msicuu2.exe) from the following Major Geeks page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    (2) Doubleclick the msicuu2.exe file and follow the prompts to install the Windows Installer CleanUp utility. (If you're on a Windows Vista or Windows 7 system and you get a Code 800A0046 error message when doubleclicking the msicuu2.exe file, try instead right-clicking on the msicuu2.exe file and selecting "Run as administrator".)
    (3) In your Start menu click All Programs and then click Windows Install Clean Up. The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
    (4) In the list of programs that appears in CleanUp, select any Bonjour entries and click "Remove", as per the following screenshot:
    (5) Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • How to set setRowKey value when table is populated dynamically

    Hi All
    I have created a view object using only select statement and displaying all the records in it in the table at page load. Table is SelectMany. Now after selecting some records I press submit button. At the backend logic is executed which prints how many rows selected and the values of the selected rows. Everything works fine till here.
    Now when the view object is modified by putting where clause. And the parameter to this where clause is coming from url. When the page is loaded table displays only records based on filter criteria. But the problem begins when I press the submit button. It shows the error: row is null for rowKey:oracle.jbo.Key[AAAQkHAAJAAAACkAAA ]
    I have done some research and found that row key is not set for the displayed records. because at the backend when I am printing the values of keys in selectionState.KeySet it prints only null.
    This thing happens only when table is populated dynamically through url value.
    Can anyone help me how to get the selectionState.Keyset values when table is populated dynamically?

    SOLVED:
    Actually there is no problem with the rowKeys as I mentioned in the post. What happened was that I was executing the query everytime on page load. Second time when the page is loaded the param value was set to null. So row becomes null but on the other hand I am referring the rows by some selected row keys. so the error that row is null for key...
    So now i am storing the param value in managed bean and then referring it in the code.

  • I had to change my Apple ID. However, it won't change in my phone. I changed it in setting, but when it comes to downloading updates for apps or music, it won't update from my old Apple ID.

    However, it won't change in my phone. I changed it in setting, but when it comes to downloading updates for apps or music, it won't update from my old Apple ID. For instance, I had to change my apple ID from (for instance, "[email protected]") to something else ("[email protected]"). I changed it in settings to the new one, but when I go to update apps, my phone is still connected to "[email protected]"
    What should I do?

    In the Finder do a Get Info on one of those files & the folder it's in, report what it says for privileges.
    Oh, did you maybe change your short username/Home Folder's name?

  • Update values set values

    Dear Users,
    I am facing one issue in HRMS:
    i have a list of jobs defined in a translated value set.
    whenever i am updating one value in the value set  the changes are not affecting the job list.
    Please advice.
    Thanks

    Hi Wmaarbani,
    What is the validation type on your value_set. Is it translatable Dependent ?
    You can search for the values from -
    Navigate to Application Developer --> Flexfield --> Key --> Values
    On this form, you will see a small Globe on the menu bar.. make sure all the translatable values are updated.
    Cheers,
    Vignesh

  • Issue when updating a trigger

    I have a trigger that is supposed to insert when a button is pressed and update when a different button is pressed. When inserting, everything works but when updating, UPDATED_ON and UPDATED_BY is put in the database but VOIDED_BY,VOIDED_ON,ARCHIVED_BY,ARCHIVED_ON are not. I am not sure what i need to do in order to fix this. Can anyone help me out here? Thanks
    Deanna
    create or replace trigger "CHART_BEFINSUPD"
    BEFORE
    insert or update or delete on "CHART"
    for each row
    DECLARE
    v_VOIDED_ON number;
    v_UPDATED_ON number;
    v_ARCHIVED_ON number;
    begin
    --v_voided_on :=0;
    --v_updated_on :=0;
    --v_archived_on :=0;
    IF INSERTING AND :NEW.RECNUM IS NULL THEN
    SELECT CHART_SEQ.NEXTVAL INTO :NEW.RECNUM FROM DUAL;
    END IF;
    IF INSERTING THEN
    :NEW.CREATED_BY := NVL(V('APP_USER'),USER);
    :NEW.CREATED_ON := SYSDATE;
    :NEW.STARTED_ON := SYSDATE;
    :NEW.STARTED_BY := NVL(V('APP_USER'),USER);
    --:NEW.ARCHIVED_BY := NVL(V('APP_USER'),USER);
    --:NEW.ARCHIVED_ON := SYSDATE;
    END IF;
    if UPDATING THEN
    :NEW.UPDATED_BY := NVL(V('APP_USER'),USER);
    :NEW.UPDATED_ON := SYSDATE;
    END IF;
    if VOIDED='Y' THEN
    :NEW.VOIDED_BY := NVL(V('APP_USER'),USER);
    :NEW.VOIDED_ON := SYSDATE;
    else
    :NEW.ARCHIVED_BY := NVL(V('APP_USER'),USER);
    :NEW.ARCHIVED_ON := SYSDATE;
    END IF;
    end;

    ok, I decided to take out of the trigger the code about archiving, since that is the part that seems to be giving me the most trouble. The rest of the trigger now works.
    So could i just write a procedure for just the archiving part? And if so how would that be done so that the procedure would run on a click of a button?
    create or replace trigger "CHART_BEFINSUPD"
    BEFORE
    insert or update or delete on "CHART"
    for each row
    begin
    IF INSERTING AND :NEW.RECNUM IS NULL THEN
    SELECT CHART_SEQ.NEXTVAL INTO :NEW.RECNUM FROM DUAL;
    END IF;
    IF INSERTING THEN
    :NEW.CREATED_BY := NVL(V('APP_USER'),USER);
    :NEW.CREATED_ON := SYSDATE;
    :NEW.STARTED_ON := SYSDATE;
    :NEW.STARTED_BY := NVL(V('APP_USER'),USER);
    END IF;
    if UPDATING THEN
    :NEW.UPDATED_BY := NVL(V('APP_USER'),USER);
    :NEW.UPDATED_ON := SYSDATE;
    END IF;
    if updating and :new.voided='Y' then
    :NEW.VOIDED_BY := NVL(V('APP_USER'),USER);
    :NEW.VOIDED_ON := SYSDATE;
    END IF;
    --IF UPDATING AND :new.ARCHIVED_BY IS not NULL THEN
    --:new.ARCHIVE :='Y';
    --:NEW.ARCHIVED_BY := NVL(V('APP_USER'),USER);
    --:NEW.ARCHIVED_ON := SYSDATE;
    --end if;
    --if updating and :new.archived_by is null then
    --:new.archive :='N';
    --if v_archive > 0 then
    --:new.archived_by := null;
    --:new.archived_on := null;
    --end if;
    --end if;
    END;Edited by: Dclipse03 on Oct 7, 2009 6:57 AM

  • Setting DateFormat when we update in SalesForce DB

    Hi,
    I want to set DateFormat before updating the date in
    SalesForce Database. I am able to update the date if i select the
    date/month which is greater than 9. Means If i select the date
    10/10/2007 ([MM/DD/YYYY or DD/MM/YYYY format]) its
    updating/inserting the data in SalesForce DB. if i select date
    9/10/2007 it is not updateing why because In SalesForce DB it will
    accept date/month in two digit format --> 09/10/2007 or
    05/08/2007 but not 9/10/2007 or 5/8/2007. Is there any solutions to
    set the dateformat using ActionScript before updating/Inserting the
    date in SalesForce Database.
    Thanks in advance

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by JDev Team ():
    Hi,
    I need to know some more details to know exactly why the field is not appearing.
    1. Is this an attribute that was included in your EO when you first created it, or one that you added later?
    ARCHANA : This attribute was not included later. It was there when I first created it because it is the "Code" which is the primary key.
    2. Is this attribute in the View Object your JSP insert page is based on?
    ARCHANA: Yes, It is there in the View Object.
    3. Is the View Object your JSP insert page is based on made up of one EO, or is it based on more than one EO?
    ARCHANA : The View Object is based on one EO only.
    4. In your JSP, you can try adding the following code to see if the attribute field will get displayed:
    <jsp:useBean id="RowEditor" class="oracle.jbo.html.databeans.EditCurrentRecord" scope="request">
    <%
    RowEditor.initialize(application, session , request, response, out, "theModule.theView");
    RowEditor.setTargetUrl("theView_SubmitInsertForm.jsp");
    RowEditor.createNewRow();
    RowEditor.setReleaseApplicationResources(true);
    RowEditor.setDisplayAttributes("Attr1,Attr2...");
    (enter the names of the attributes you want displayed in the setDisplayAttributes method.
    Laura<HR></BLOCKQUOTE>
    Actually my JSP has exactly the same code as u have sent. I have included "Code" in my setDisplayAttributes() method also. The label for this attribute appears but adjacent to it there is no text control to type the data when I insert data.
    Please explain.
    null

Maybe you are looking for

  • Ipod Touch 1st Generation Power On Problem?

    I own a 1st generation ipod touch which l cannot access. I was updating an app then my ipod froze which led to a full power-off. I turned the ipod back on. The apple logo will come up after holding the power on button, but my ipod touch was turning o

  • Search Help Exit

    Hi all,   I have a requirement to override a standard search help. The requirement is to bring search help of infotype1028's (address) standard field from a custom table instead of bringing it from a standard table. As it is not possible to do anythi

  • Passing values to BAPI's - pls help

    Hi, I have some datas in z-table, I want to pass that datas to IW31 tr-code. I collected all BAPI's and I need help about How to call and Pass the values through BAPI. Pls help me..... Thanks in Advance, Sunil

  • ESS Business Package 60.2

    Hello All! I need to download the ess business package 60.2 and I don't where i can find it. Could you please help me with that? Yours, Hajar

  • Trigger mail to dynamic Agents

    Hi Experts, My requirement is to trigger a email to user based on document type. Lets say my doc. type is     DOC1 then Approver will be USER1                                             DOC2 then  Approver will be USER2. and mail should be triggered