Help on update

Hi All ,
I am trying to INSERT updated_by and Updated_date with ctut_id and sysdate
When user trying to update any record.
IF USER scott is logged into system and trying to update table
Then I need to get his id number(CTUT_ID) into updated_by
And sysdate into updated_date
Suppose
SQL> select * from ora_system_user;
CTUT_ID CURRENT_USER_ID CREATED_BY CREATED_D UPDATED_BY UPDATED_D
117 KKING 117 15-MAY-03
118 SCOTT 117 15-MAY-03
119 EXAMPLE1 117 15-MAY-03 117 15-MAY-03
120 EXAMPLE2 117 15-MAY-03 118 15-MAY-03
121 EXAMPLE3 117 15-MAY-03 117 15-MAY-03
Here is my code
SQL> DESC ORA_SYSTEM_USER
Name Null? Type
CTUT_ID NOT NULL NUMBER(12)
CURRENT_USER_ID NOT NULL VARCHAR2(30)
CREATED_BY NUMBER(12)
CREATED_DATE DATE
UPDATED_BY NUMBER(12)
UPDATED_DATE DATE
•     PLSQL temporary tables are contained in a package
•     To ensure that variables are global is to put in a package
CREATE OR REPLACE PACKAGE SYSTEMUSER as
TYPE t_UPDATED_BY is TABLE OF ora_system_user.UPDATED_BY%TYPE
INDEX BY BINARY_INTEGER;
TYPE t_UPDATED_DATE is TABLE OF ora_system_user.UPDATED_DATE%TYPE
INDEX BY BINARY_INTEGER;
TYPE t_CTUT_ID is TABLE OF ora_system_user.CTUT_ID%TYPE
INDEX BY BINARY_INTEGER;
U_SYSTEMUPDATEDBY T_UPDATED_BY;
U_SYSTEMUPDATEDDATE T_UPDATED_DATE;
U_SYSTEMCTUTID T_CTUT_ID;
U_NUMENTRIES BINARY_INTEGER := 0;
END PA_TDBX_UPD_ORASYSTEMUSER;
•     This Trigger will use to insert the values for Created_date and Created_by columns
•     A counter variable V_NUMENTRIES is used .
•     So that Statement level trigger references it and then resets to zero after processing.
•     This is necessary ,so that next statement issued by this session will have the correct value.
CREATE OR REPLACE TRIGGER TIBU_SYSTEMUSER
BEFORE UPDATE ON ORA_SYSTEM_USER
FOR EACH ROW
BEGIN
IF :NEW.CREATED_DATE <> :OLD.CREATED_DATE
THEN
:NEW.CREATED_DATE := :OLD.CREATED_DATE;
END IF;
IF
:NEW.CREATED_BY <> :OLD.CREATED_BY THEN
:NEW.CREATED_BY := :OLD.CREATED_BY;
END IF;
:NEW.UPDATED_DATE := ‘1-JAN-2003’;
:NEW.UPDATED_BY := 0;
SYSTEMUSER.U_NUMENTRIES :=
SYSTEMUSER.U_NUMENTRIES + 1;
SYSTEMUSER.U_SYSTEMUPDATEDBY(SYSTEMUSER.U_NUMENTRIES) := :NEW.UPDATED_BY;
SYSTEMUSER.U_SYSTEMUPDATEDDATE(SYSTEMUSER.U_NUMENTRIES) := :NEW.UPDATED_DATE;
SYSTEMUSER.U_SYSTEMCTUTID(SYSTEMUSER.U_NUMENTRIES) := :NEW.CTUT_ID;
END TIBU_SYSTEMUSER;
This Trigger is used to set the columns Created_by, Created_date when inserting values
CREATE OR REPLACE TRIGGER TIAU_ORASYSTEMUSER
AFTER UPDATE ON ORA_SYSTEM_USER
DECLARE
U_ID NUMBER;
U_CTUTID ORA_SYSTEM_USER.CTUT_ID%TYPE;
U_CREATEDBY ORA_SYSTEM_USER.CREATED_BY%TYPE;
U_CREATEDDATE ORA_SYSTEM_USER.CREATED_DATE%TYPE;
CUBY NUMBER(12);
BEGIN
FOR U_LOOPINDEX IN 1..SYSTEMUSER.U_NUMENTRIES LOOP
U_CTUTID := SYSTEMUSER.U_SYSTEMCTUTID(V_LOOPINDEX);
U_CREATEDBY := SYSTEMUSER.U_SYSTEMCREATEDBY(V_LOOPINDEX);
U_CREATEDDATE := SYSTEMUSER.U_SYSTEMCREATEDDATE(V_LOOPINDEX);
SELECT COUNT(*) INTO U_ID
FROM ORA_SYSTEM_USER
WHERE CURRENT_USER_ID = USER;
IF U_ID > 0 THEN
SELECT CTUT_ID INTO CUBY
FROM ORA_SYSTEM_USER
WHERE CURRENT_USER_ID = USER;
UPDATE ORA_SYSTEM_USER
SET CREATED_DATE = SYSDATE,
CREATED_BY = CUBY
WHERE CTUT_ID = U_CTUTID;
ELSE
RAISE_APPLICATION_ERROR(-20000,'NO USER FOUND IN TABLE');
END IF;
END LOOP;
SYSTEMUSER.U_NUMENTRIES := 0;
END TIAU_ORASYSTEMUSER;
I am getting the following errors
SQL> UPDATE ORA_SYSTEM_USER
2 SET CURRENT_USER_ID = 'EXAMPLE10'
3 WHERE CTUT_ID = 119;
UPDATE ORA_SYSTEM_USER
ERROR at line 1:
ORA-00036: maximum number of recursive SQL levels (50) exceeded
ORA-00036: maximum number of recursive SQL levels (50) exceeded
ORA-00036: maximum number of recursive SQL levels (50) exceeded
ORA-06512: at "TIAU_ORASYSTEMUSER", line 13
ORA-04088: error during execution of trigger 'KKISHORE.TIAU_ORASYSTEMUSER'
ORA-06512: at " TIAU_ORASYSTEMUSER", line 20
ORA-04088: error during execution of trigger 'KKISHORE.TIAU_ORASYSTEMUSER'
ORA-06512: at " TIAU_ORASYSTEMUSER", line 20
ORA-04088: error during execution of trigger 'KKISHORE.TIAU_ORASYSTEMUSER'
ORA-06512: at "TIAU_ORASYSTEMUSER", line 20
ORA-04088: error during execution of trigger 'KKISHORE.TIAU_ORASYSTEMUSER'
ORA-06512: at " TIAU_ORASYSTEMUSER", line 20
ORA-04088: error during execution of trigger 'KKISHORE.TIAU_ORASYSTEMUSER'
ORA-06512: at "TIAU_ORASYSTEMUSER", line 20
ORA-04088: error during execution of trigger 'KKISHORE.TIAU_ORASYSTEMUSER'
ORA-06512: at "TIAU_ORASYSTEMUSER", line 20
ORA-04088:

Whenever you update ora_system_user, you update ora_system_user, which results in an update to ora_system_user, etc. You have an infinite recursion.
I think the FOR EACH ROW trigger should only add items to the PL/SQL tables if a column other than the created_by/date and updated_by/date is updated.

Similar Messages

  • HT4623 please help me update ios 4.3 in iphone 3g

    please help me update ios 4.3 in iphone 3g

    You can't. The iPhone 3G can only go as high as iOS 4.2.1. It hardware does not suport a higher iOS.
    BW this is the iPod touch forum.

  • Tabs only open in a new window. Ctl T opens a new window NOT a new tab help-last update this problem started. How do I set FF back to open tabs in 1 window

    Tabs only open in a new window. Ctl T opens a new window NOT a new tab help-last update this problem started 2 days ago. How do I set FF back to open tabs in 1 window?
    There is no plus sign and going into optins and changing settings has not worked. I have uninstall FF and reinstall-keeping my personalization-and that was no help.
    Right clicking on FF Icon to open a new tab, or going up to FF drop down tab and clicking on new tab both do not work.
    Help everything opens a new window not a new tab. there seems to be no way to reset this or to chose a different optin. I just downloaded new tabs at end addon and it didn't do a thing.

    as a first troubleshooting step - does it work like normally when you open & run firefox in [[Safe Mode|safemode]] by pressing the shift key while you open firefox (all other instances have to be closed before)...

  • Need help in UPDATE data in SQL Query

    Hi all,
    I am trying to update data in the sql table as per below screenshot but couldn't able to do it. Can anyone help to update the data as I mention in screenshot.Appreciate you help.Thanks.
    Yellow highlighted columns are source
    Green highlighted columns are target
    Colored data should be update as per source data in sql table.Data is not static as it might have more rows to update and query should be bit dynamic.
    Maruthi...

    You have already asked this question once. You did not get any good answers, because you the information you gave was insufficient. And I'm afraid that the information is still in sufficient.
    Or more exactly, from the example you have given, the answer is: can't be done. And the reason it can't be done, is as I explained in response to you first thread: there is no information in the data to from which we can deduce that Clorox Company
    should be under "Week 1-1,K.B,F". The fact that rows are listed in a certain order in the screenshoot is of no importance, because a table is an unordered object.
    But you said in another post that you have a timestamp column. Maybe that column is usable - maybe it is not. But at least it is a key that you have more columns that the ones you show.
    The best way to get help with this type of problems is to post:
    1) CREATE TABLE statement for your table(s).
    2) INSERT statements with sample data.
    3) The desired result given the sample.
    4) A short description of the actual buisness problem you are trying to solve.
    5) Which version of SQL Server you are using.
    This makes it easy to copy and paste into a query window to develop a tested solution. Screenshots with an insufficient amount of data is not going to help you very much.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • HELP! Updated to keynote 9...created a presentation (took me hours) and now it won't open and i'm being told I have to 'buy' the new keynote to open it

    HELP! Updated to keynote 9...created a presentation (took me hours) and now it won't open and i'm being told I have to 'buy' the new keynote to open it

    Keynote 6 is compatible with Mavericks only, your profile states you are using Snow Leopard, if thats the case use Keynote version 5 and all will work as before.

  • MAC OS 10.6.8 Using Safari 5.1 Needing Help With Updating Adobe Flash

    Hello-
    Recently Adobe Flash installed an icon in my System Preferences and when I click the icon there are several tabs.  One allows updates to check automatically.  It says it will install the latest version of Flash without having to remove the previous version, but I have never been told that a newer version is available unless I clcik "check now."  although "Check for updates automatically" is checked, I do not know where it tells me a newer version is available.  Also, there has been 5 "newer versions" available since this icon was installed in System Prefeences, I have only found out about the newer versions when I clicked "Check Now."  If I read that with this new way to install the latest Mac version of Flash does not require me to uninstall the previous version of Flash how do I install the most recent version of Flash?  Does it come in an email?
    Since it is not telling me that there is a more recent version of Flash unless I click "Check Now" should I still do it the way I used to install the latest version of flash?  (The way before this icon was added to System Preferences)?
    I would appreciate help with updating Flash to the most recent version.  I used to uninstall the older version, restart the browser and download the most recent version and install it.  It always worked find but this was before there was an Adobe icon in my system Preferences.

    Hello,
    The way you used to do this (uninstall, restart the browser, etc.) is still definitely valid and probably the "safest" way to get a new version installed.  Uninstalling shouldn't be required, but it definitely doesn't hurt.  If you feel comfortable doing it the old way, please feel free to continue using that process.
    As for notifications, this is a bit trickier, but in general you should be notified within 30 days (or so) after a new player is released.  This usually occurs when the browser loads swf content.  Clicking the button will, like you mention, immediately check.  Another alternative to finding out when a new player is released is to subscribe to our Flash Player Releases feed.
    Is there a way to be automatically notified when a new Flash Runtime release is made?
    Thanks,
    Chris

  • Help after updating the OS to 4.3.3 none of the 3rd party app work

    Help after updating the OS to 4.3.3 none of the 3rd party apps work at all they just flash up on the screen and then die.

    install a free app (or any other app) from the app store, then the problem will be fixed.

  • Help I updated my phone to 5.1.1

    help I updated my phone to 5.1.1 and now i cant put music on it

    What happens when you try?

  • Need a help on Update statement

    Hi All,
    I Need a help in updating a table column. PFB my requirement.
    Table1
    ItemID OrgId       Date
    1       82     12/sep/2012   
    2       82     25/oct/2012
    3       82     17/Nov/2012
    4     82     22/Jan/2013
    5     82     26/sep/2012
    Table2
    Itemid     orgid       Date1
    1      82     23/sep/2012      
    2      82     25/Dec/2012
    3      82     17/Sep/2012
    4      82     22/Feb/2013
    5      82     26/Oct/2012
    Table3
    Itemid     orgid       Date3
    1      82     10/sep/2012      
    7      82     30/Dec/2012
    3      82     12/Sep/2012
    10      82     27/Feb/2013
    5      82     29/Oct/2012
    I Need to Update Date column of Table1 With Date3 of table3
    If
    Item and org combination is present in table3 and date column of table1 is less than Date3 of table3
    Else
    I need to Update with date2 of table2.Can we acheive this in a single update statement, can any one help me on this.
    Thanks and regards,
    Rakesh
    Edited by: Venkat Rakesh on Sep 27, 2012 11:04 PM

    You can probably also use MERGE:
    --DROP TABLE table1;
    --DROP TABLE table2;
    --DROP TABLE table3;
    ALTER SESSION SET nls_language = 'AMERICAN';
    CREATE TABLE table1
       itemid    CHAR (1),
       orgid     CHAR (2),
       thedate   DATE
    INSERT INTO table1   SELECT '1', '82', TO_DATE ('10/sep/2011', 'dd/mon/yyyy') FROM DUAL;
    INSERT INTO table1   SELECT '2', '82', TO_DATE ('10/oct/2011', 'dd/mon/yyyy') FROM DUAL;
    INSERT INTO table1   SELECT '3', '82', TO_DATE ('10/nov/2011', 'dd/mon/yyyy') FROM DUAL;
    INSERT INTO table1   SELECT '4', '82', TO_DATE ('10/jan/2011', 'dd/mon/yyyy') FROM DUAL;
    INSERT INTO table1   SELECT '5', '82', TO_DATE ('10/sep/2011', 'dd/mon/yyyy') FROM DUAL;-- won't be updated
    CREATE TABLE table2
       itemid    CHAR (1),
       orgid     CHAR (2),
       thedate   DATE
    INSERT INTO table2   SELECT '1', '82', TO_DATE ('01/sep/2012', 'dd/mon/yyyy') FROM DUAL;
    INSERT INTO table2   SELECT '2', '82', TO_DATE ('01/dec/2012', 'dd/mon/yyyy') FROM DUAL;
    INSERT INTO table2   SELECT '3', '82', TO_DATE ('01/sep/2012', 'dd/mon/yyyy') FROM DUAL;
    INSERT INTO table2   SELECT '4', '82', TO_DATE ('01/feb/2012', 'dd/mon/yyyy') FROM DUAL;
    CREATE TABLE table3
       itemid    CHAR (1),
       orgid     CHAR (2),
       thedate   DATE
    INSERT INTO table3   SELECT '2', '82', TO_DATE ('30/dec/2009', 'dd/mon/yyyy') FROM DUAL; -- date less than table1, so picks from table2
    INSERT INTO table3   SELECT '4', '82', TO_DATE ('30/mar/2013', 'dd/mon/yyyy') FROM DUAL; -- larger than table1 , so pick this date
    -- table1 original data
    SELECT * FROM table1;
    -- merge new data
    MERGE INTO table1
         USING (SELECT NVL (t1.itemid, t2.itemid) itemid,
                       NVL (t1.orgid, t2.orgid) orgid,
                       t2.thedate prefdate ,
                       t1.thedate nextdate
                  FROM    table2 t1
                       FULL OUTER JOIN
                          table3 t2
                       ON t1.itemid = t2.itemid AND t1.orgid = t2.orgid) dat
            ON (dat.itemid = table1.itemid AND dat.orgid = table1.orgid)
    WHEN MATCHED
    THEN
       UPDATE SET table1.thedate = (case when prefdate > table1.thedate then prefdate else nextdate end) ;
    --table1 updated data
    SELECT * FROM table1;OUTPUT:
    Session altered.
    Table created.
    1 row created.
    1 row created.
    1 row created.
    1 row created.
    1 row created.
    Table created.
    1 row created.
    1 row created.
    1 row created.
    1 row created.
    Table created.
    1 row created.
    1 row created.
    ITEMID ORGID THEDATE  
    1      82    10.09.2011
    2      82    10.10.2011
    3      82    10.11.2011
    4      82    10.01.2011
    5      82    10.09.2011
    5 rows selected.
    4 rows merged.
    ITEMID ORGID THEDATE  
    1      82    01.09.2012
    2      82    01.12.2012
    3      82    01.09.2012
    4      82    30.03.2013
    5      82    10.09.2011
    5 rows selected.

  • Help - Software Updates has error, "No repository found"

    I just launched Flash Builder 4.7 (latest version) for the first time and went to Help -> Software Updates and get this error.
    "'Contacting Software Sites' has encountered a problem. No repository found at http://aesplugins.adobe.com/aes/tooling/plugin/10.0."
    Really sloppy, Adobe. Put this in your QA checklist!!

    So agree! Cobwebs are gathering fast on FB.

  • Flash Help Not Updating on Web

    I've uploaded a Flash help project to our web site. But the
    latest information is NOT showing up, no matter how many times I
    click refresh or clear out the associated cached files. I've even
    deleted all the items on the server and re-uploaded the entire
    project. I've verified that the file sizes and dates are
    identical...
    Yet the browser is showing an older version.
    Any else experienced this? And how do I fix it? It's
    happening in both IE and FF.
    Thanks in advance.

    Hi Jared
    Are you certain that the server has been updated? I've been
    in a few development environments where you uploaded initially to a
    staging server. Then after a certain period of time, the staging
    server would update to one or more production servers. So depending
    on the timing as well as the server you are accessing at the time
    (Important to note that, as load balancing and whatnot can present
    different servers depending on the load) you may see that help has
    updated properly on one server and the next page refresh shows it
    hasn't yet updated to the other.
    Things to ponder... Rick

  • 10.1.4 library file missing for help and update not working

    Just updated to AR 10.1.4 and everything seems to be working except the help and update functions are not working. I get the message that the library help file is missing. I uninstalled and reinstalled in both FF15 anf IE9 with the same result and I installed from both Adobe and FileHippo with the same result. Anybody have any suggestions?

    On the AR 10.1.4 tool bar menu click the "Help" item and the drop down screen shows a number of items to select from. If I click on "Adobe Reader X Help" I get a message saying "the library file is missing and I should reinstall". As for "check for updates" nothing happens. I've uninstalled and reinstalled AR 10.1.4 from two different browsers, IE9 and FF 15 with no difference. I'm using Vista 32 bit OS.

  • Help with updates for CS6

    I need help installing latest updates for CS6.  I have Win 7 and have tried updating from the Help - Updates menu.  The error is:  U43M1D207.

    Thanks for your response.  I am in the United States in So. Arizona.
    Date: Fri, 5 Oct 2012 12:21:45 -0600
    From: [email protected]
    To: [email protected]
    Subject: Help with updates for CS6
    Re: Help with updates for CS6 created by Jeff A Wright in Downloading, Installing, Setting Up - View the full discussion
    Crunkle1 you are welcome to work directly with our support team for guided assistance.  If you go to http://www.adobe.com/ and select Help and Contact Us you should be given the option to contact our support team via telephone.  Which country/region are you in?
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/4752605#4752605
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4752605#4752605
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4752605#4752605. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Downloading, Installing, Setting Up by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Help.after updating my os5, my app store icon is gone and i cant access my store!!!what is going on, Help.after updating my os5, my app store icon is gone and i cant access my store!!!what is going on

    Help.after updating my os5, my app store icon is gone and i cant access my store!!!what is going on, Help.after updating my os5, my app store icon is gone and i cant access my store!!!what is going on

    You're not talking to a team of Apple employees poised to jump on your question.  We're all just users here, and we might be doing something else...
    You cannot delete the App store App. It is somewhere on your Home screens, or you have dragged it into a folder. Any folder. If all else fails Settings > General > Reset > Reset Home Screen Layout.

  • Photoshop Elements crashed on my MAC and gave me the suggestion to go to Help, then Updates to correct the problem.  When I do this the update starts and then tells me to close Elements to continue.  I close Elements and continue then get this message - P

    Photoshop Elements crashed on my MAC and gave me the suggestion to go to Help, then Updates to correct the problem.  When I do this the update starts and then tells me to close Elements to continue.  I close Elements and continue then get this message - PLEASE CLOSE THE FOLLOWING APPLICATIONS TO CONTINUE - ElementsAutoAnalyzer AND ElementsOrganizerRevelAgent.  I have no idea how to close these applications and therefore I am not able to get the updates.

    Applications>Utilities>Activity Monitor and you can kill them there.

  • Please help i updated my iphone 4 to 5.0.1 and couldn't restore the back up of the older version,but I still have the folder of the older back up in AppleComputer,mobilesync please help !! thanks in advance

    Please help i updated my iphone 4 running iOS 4.3.3 to 5.0.1 and couldn't restore the back up of the older version,but I still have the folder of the older back up in AppleComputer,mobilesync please help !! thanks in advance

    if you want an intelligent answer, you'll have to provide intelligent information.
    WHY couldn't you restore the order backup?  Was there an error message?  What EXACTLY was the error message?

Maybe you are looking for