fetch the BONE inside an INSERT/UPDATE trigger USER?

HI guyz,

I'm checking a table based on inserts and updates on this topic, I write the following trigger

CREATE TABLE emp_audit)
old_empno number 4,
old_ename VARCHAR2 (10),
old_job VARCHAR2 (9).
old_mgr number 4,
old_hiredate DATE,
old_sal NUMBER (7.2).
old_comm NUMBER (7.2).
old_deptno NUMBER (2),
new_empno number 4,
new_ename VARCHAR2 (10),
new_job VARCHAR2 (9).
new_mgr number 4,
new_hiredate DATE,
new_sal NUMBER (7.2).
new_comm NUMBER (7.2).
new_deptno NUMBER (2),
changed_by VARCHAR2 (8).
change_type char (1),
timestamp DATE);

CREATE OR REPLACE TRIGGER LogEmpChanges
Before you INSERT or REMOVE or UPDATE ON scott.emp
FOR EACH LINE
DECLARE
v_ChangeType char (1);
BEGIN
/ * Use 'I' for an INSERT, d ' to REMOVE and 'U' for UPDATE. */
IF THE INSERTION
v_ChangeType: = 'I ';
ELSIF UPDATE THEN
v_ChangeType: = 'U ';
ON THE OTHER
v_ChangeType: = ';
END IF;

/ * Save all changes to scott.emp in
emp_audit. SYSDATE can generate the timestamp, and
USER to return the current user's user ID. */
INSERT INTO emp_audit
(change_type, changed_by, timestamp, old_empno,
old_ename, old_job, old_mgr, old_hiredate, old_sal,
old_comm, old_deptno, new_empno, new_ename, new_job,
new_mgr, new_hiredate, new_sal, new_comm, new_deptno)
VALUES
(v_ChangeType, USER, SYSDATE,: old.empno,: old.ename,)
: old.job,: old.mgr,: old.hiredate,: old.sal,: old.comm,.
: old.deptno,: new.empno,: new.ename,: new.job,: new.mgr,.
(: new.hiredate,: new.sal,: new.comm,: new.deptno);
END LogEmpChanges;
/

I need to get the user to the BONE, like going looking for 'USER' will not help because there is that one user of the application that connects to the database, we can trap the user with the 'OSUSER"that displays in the view ' V$ SESSION.

Please give some suggestions...

user1221 wrote:
Actually I auditied the changes on the table by using the updated the triggered, but our application in this case is client server and there is that one user that connects to the database and whenever the table is changed the verified info is for a single user ie; the main user of the application, if I can read the user of the OS or the name of the computer where the connection is established, which will be useful for us.

You can include what you want accordint notice of the [SYS_CONTEXT | http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions165.htm#SQLRF06117]

Instead of the MACHINE, use the HOST

Published by: Kamran Agayev, a., October 10, 2009 18:18

Tags: Database

Similar Questions

  • After that insert update trigger does not work properly

    Hello experts!

    I created an insert/update trigger after and what strikes me is that it does not work as expected.
    The trigger starts a procedure that performs an insert in a second case of changing values table triggered table ("my_table").

    The problem is that in my second table values, which are correlated to the "my_table", are not changed by the correct values immediately. The trails of the trigger and insert!

    I need to update two times to values appear in my second table. Then only the data of the first update will be inserted in the second recital to table the table parent ("my_table") held the most recent values.

    Do you have an idea what could be the problem?
    create or replace
    trigger myscheme.after_update_insert_set_tw
     after update or insert
      on myscheme.my_table
      for each row
      
    declare 
    
    begin
    
     pr_my_table_tw_sync_sk(:new.lng_falle, :new.int_fallennummer, :new.lng_schaedling, :new.objectid);
    
    
    end;
    Brgds,

    SEB

    Remove the pragma autonomous_transaction and validation of your relaxation. This might be the reason. The transaction autonoumous cant properly consider the values of the current transaction (which is not engaged yet).

    This is not logically (if the upgrade fails or is rolled at the time you do not want the inserted row).

    If you then get a problem because the mutation of tables, you will need a different solution: an autonoumous transaction is not the right solution to workaround.

  • What is the best way to store the RCS for an insert/update in this rec

    Oracle on Win 64 non-conteneur 12.1.0.2

    When a record in one table is inserted or updated, what would be the best way to store the RCS for this record in this folder.

    I thought of a line after trigger, but did not know if this trigger to store the current_scn would still fire that trigger again (recursive trigger).

    Someone at - he a good idea of what the best way is to do?  The devs don't want to store the pk and the SNA in yet another table...

    Yes, row_dependencies would be the best way to go.  But mgmt doesn't recreate all tables for this.

    3rd party applications retrieve data from tables (all data).  We are looking for a way for them to just pull what is new or updated updated since their last sweater.

    I suggest that you try again and give all OF THE REQUIREMENTS.

    You have rejected ANY answer given and he justified using 'hidden' on what knowledge management or the devs want or do not want to. Stop making us guess what are the requirements and constraints. If you want a real answer then tell us ALL the news.

    When a record in one table is inserted or updated, what would be the best way to store the RCS for this record in this folder.

    Solomon answered repeatedly. If you want to add a column to a table to store the then "best" SNA is to let the Oracle to do this for you automatically by using the DEPENDENCY LINE.

    As he says also re-create the table to add this clause will be MUCH MORE EFFECTIVE that everything THAT you can do it manually. It will be also more accurate because Oracle will fill the value ORA_ROWSCN with the SNA at the time the line was committed. You, as long as user, can't fill a column in function when a line is engaged since real VALIDATION belongs to a transaction, not the line or the trigger that you use.

    Yes - there are two drawbacks to this method:

    1. you need to re-create the table

    2. you cannot add an index to this "hidden" column

    The devs don't want to store the pk and the SNA in yet another table...

    Then? Who cares what the devs want to do? You want the BEST solution? Next, you will need to put aside personal preferences and determine what is the 'best' solution. Why it is important that certain dev wants to do this or not?

    OK, the problem of biz is now, 3rd party external users are an all-wheel drive large number of tables in the database via the API that we wrote.  That was obviously interrupted OLTP during the day.  To reduce to the minimum, we want for them just to extract data that has been inserted/updated since their last sweater.

    It is the definition of a "replica" DB Then why don't you consider a real replicated DB? You can use DataGuard and have replicated DB which is read only that can be used to generate reports. Oracle does ALL the work to keep ALL the tables in sync. You and your developers do NOTHING!

    We thought that store the RCS higher their last sweater would allow the API to extract only data with YVERT higher than their last data pull CHN.

    OK - except you keep rejecting solutions actually do. Ask you questions about the SNA stored in the same table, but then reject the solution that does this. And then you add your "devs" don't want to store the info in a new table either.

    Then your solutions must ONLY use the replication or Log Miner. The REDO logs have all changes, if you want to extract yourself. Replication (e.g., DataGuard) will use these logs for you to maintain a replicated database.

    We thought about it, but recreate all tables in production with ROWDEPENDENCIES as well as dealing with CF and other dependencies idea this was shot.

    Well you NEVER mentioned you "thought that" and rejected it. And you NEVER mentioned anything about FKs and other dependencies. What is FKs and other dependencies which prevents this working solution? Tell us! Give us ALL the information.

    Wouldn't a trigger AFTER LINE capture the commit YVERT?  Or is after really not after validation?

    No - a trigger has NOT one commit. A trigger runs as a step in a transaction. Validation applies to the entire transaction. Until you, or Oracle, issues a commit, there is NO "committed SNA" to be stored as ORA_ROWSCN.

    You can easily see that for yourself. Create a simple table with dependencies of the line and then update two different sessions.

    create the table emp_scn rowdependencies in select * from emp where rownum<>

    Select empno, emp_scn ora_rowscn

    Update emp_scn set work = 'b' where empno = 7499

    commit;

    The first SELECT statement will show you that each row has the same SNA.

    EMPNO, ORA_ROWSCN

    7369,70622201

    7499,70622201

    7521,70622201

    Now, do the update (but no commit), then SELECT it

    EMPNO, ORA_ROWSCN

    7369,70622201

    7499,

    7521,70622201

    Where is the value of 7499? This session will NOT see a value for the changed lines in the current transaction. Other sessions will still see the old value.

    Now do the validation, then SELECT

    EMPNO, ORA_ROWSCN

    7369,70622201

    7499,70622301

    7521,70622201

    7499 now has a new and different value than the other lines. It will not be this new value until the validation occurs.

    Yes, row_dependencies would be the best way to go.  But mgmt doesn't recreate all tables for this.

    Well, you got the answer you want. You ask the best way. Now, you say that you were told the best way. But now you don't like the answer.

    How is it our fault? Your question has been answered wasn't she?

    Here are the facts:

    1 oracle creates a history of changes - the REDO log files

    2. you can use Log Miner to extract these changes

    3. you can create your own change log by adding a log file of MV to your table.

    4. you can then write a custom code to use this MV log file to determine which rows to "reproduce".

    So far reject you all THE POSSIBLE solutions.

    Accept it or change the requirements to allow one of the solutions proposed to be used.

    Personally, if I HAD to use a customized solution, I would use a MV journal to record the ROWID of the lines that have changed (for tables ROWID cannot be changed). I would then extract the appropriate lines by pulling on the lines corresponding to these row ID.

    Even that has problems since a line can be changed several times and children lines can also be amended several times - these questions FK you mentioned.

    I suggest you read this entire thread on AskTom a dozen years ago. It addresses ALL these issues.

    https://asktom.Oracle.com/pls/Apex/f?p=100:11:0:P11_QUESTION_ID:16998677475837

    Then in your next reply on this topic give us a summary of where some things with your question and what help you further expect.

  • user who has the rights to select/insert/update

    I want to know what user has select, insert, update, delete, run, rights on the tables of the ERP.

    concerning

    oracleRaj wrote:
    I want to know what user has select, insert, update, delete, run, rights on the tables of the ERP.

    concerning

    Mark from dba_tab_privs according to the table of ERP

  • Needs of the BONES tool (was: Adobe Flash CC)

    In Adobe Flash CC, unfortunately tool OS is not advisable. May I know is there any recommended tool to replace the BONE tool?

    Update Flash CC TI 2015 contains a BONE tool.

  • Insert, update, delete

    If I have a cfquery with the data name and relevant source etc. then the sql will be the same for:

    1 insert, update, delete with mysql and mssql?
    2. trade unions and different joins for mysql and mssql?

    Thank you!

    When you compare two db, it is reasonable to assume that they will behave the same if you stay plain vanilla sql and that there will be at least a difference when it comes to features.

  • approximate number of inserts, updates and deletions

    Hello
    in 10 g with STATISTICS_LEVEL = TYPICAL
    How to see the approximate number of inserts, updates, and deletes for a specific table?

    Thank you.

    This table has been abandoned - but segment still exists – and 'strange' name comes from the management of the recyclebin.

    Nicolas.

  • trigger check the previous record of line before insert/update

    Hi all

    I would like to create a trigger that a customer will not be able to create a new account, if it has a status of "Non-payment".

    CustomerID custNRIC paymentStatus

    ----------------------------------------------------------------

    Non-payment of 200 F7654323A

    It will reject the following statement.

    insert into customer (custID, custNRIC, paymentStatus) VALUES (201, 'F7654323A', 'Good');

    so, how can I go around to solve this issue?

    sqlnoob wrote:

    Hi all

    I would like to create a trigger that a customer won't be able to create a new account, if it has a "Non-payment" statusYou

    You can't do things like that in a trigger.

    It will reject the following statement.

    insert into customer (custID, custNRIC, paymentStatus) VALUES (201, 'F7654323A', 'Good');

    The trigger would dismiss as EVERY other row in the same transaction, if you try to use a trigger.

    You can't stop a trigger to run except by raising an exception and the trigger stop from doing anything for ANY line that the trigger activated on.

    together to define

    CREATE OR REPLACE TRIGGER reject_new_account

    AFTER INSERT OR update ON the client

    FOR EACH LINE

    DECLARE

    PRAGMA AUTONOMOUS_TRANSACTION;

    totover NUMBER (3);

    BEGIN

    SELECT COUNT (*)

    IN totover

    OF THE customer

    WHERE: NEW.nric = customer.nric

    AND: NEW.badstatus = "Non-payment";

    Why are you tring to use an autonomous transaction? All that makes the transaction will NOT be part of the transaction that fired the trigger.

    I know there is a problem with the line 13 ' AND: NEW.badstatus = "Non-payment".»

    so, how can I go around to solve this issue?

    This is the LEAST of your problems. Do NOT try to nontransactional things in a trigger.

    Also, don't try to query the table that the trigger is activated on.

    This is the fundamental question: Oracle is a multi-user system. Other users may be perform DML on the same table at the same time. So any NUMBER that provides this trigger can turn out to be inaccurate when other users post their transactions.

    The best you can do in a trigger is throw an exception. If you do this will affect the complete relaxation and all the lines he treated - not only one line you see that you want to reject.

    A requirement like yours needs to be satisfied by the presence of DML performed using functions or procedures and serialize the customer INSERT/update this transaction that a SINGLE session/user/can perform DML on the table for a client given.

  • How to capture information on what program is inserting/updating of the data in the table?

    Hello


    I'm working on an application where we have an ABC chart that has a STATUS column. This column is updated from somewhere.

    However, we are unable to determine where this COLUMN is updated. I checked the DBA_SOURCE table to see if this table is updated from any oracle proc / function. But isn't.

    Is there anyway that I can identify what program will update this table? I can create a before update trigger but I'm not sure if that I can capture program (shell script / informatica workflow) that is updated in this table.

    You can use in a trigger SYS_CONTEXT 'USERENV' information ' MODULE'

    create table mytable
    (
      col1   VARCHAR2(10)
    , col2   VARCHAR2(50)
    );
    
    create or replace trigger mytable_bi_trigger
    before insert
    on mytable
    for each row
    begin
    
        :new.col2 := SYS_CONTEXT('USERENV','MODULE');
    
    end;
    /
    
    -- from Toad
    insert into mytable(col1) values('Test 1');
    commit;
    -- From sqlplus
    insert into mytable(col1) values('Test 2');
    commit;
    
    select * from mytable;
    
    COL1       COL2
    ---------- --------------------------------------------------
    Test 1     TOAD 11.0.0.116
    Test 2     SQL*Plus        
    

    You can also capture a lot more information (host name of the client, the os user, etc.).

    See http://docs.oracle.com/database/121/SQLRF/functions199.htm#SQLRF06117

    Kind regards.

    Alberto

  • With the help of Merge for Update, Insert, Update and also to delete outdated records

    Hi all!!!

    Suppose that a credit memo the following table called Orders:
    ORDERID        STATUS      PRICE 
    ---------- ---------- ---------- 
             1          0        100 
             2          0        200 
             3          0        300 
             4          0        350 
             5          0        390
    In addition, there are a procedure that will generate data on a global temporary table, called Orders_Temp. This temporary table will be used to update the Orders table. + commands + have a trigger that will perform different operations when an Insert, Update, or Delete command is executed.

    Consider the table of Orders_Temp to have the following data after you run a procedure that is responsible for the update of order data:
    ORDERID        STATUS      PRICE 
    ---------- ---------- ---------- 
             1          1        100 
             2          2        200 
             3          0        300 
             5          0        390 
             6          0        350
    As you can see, orders 1 and 2 have been updated. Order 3 and 5 were intact, order 4 has been deleted and command 6 inserted. Fusion will take care of properly manage orders 1, 2, 3, 5 and 6, although producing an update of order 3 and 5, which have not changed.

    So, here are the questions:
    (1) how could remove the 4 arrestedorder, as this order was not present on Orders_Temp? Is it possible to use the merge command to do this?
    (2) is it possible to generates not a update operation for orders of 3 and 5, which have not changed?

    I m using Oracle 10.2 SE.

    Thank you very much!
    Regis

    Hello

    Please try this. Not tested! with 9i. I think you can do this by using the union all.

    MERGE INTO orders tgt
     USING (SELECT A.*, 1 mask
              FROM orders_temp A
            UNION ALL
            SELECT A.*, 0
              FROM orders A
             WHERE NOT EXISTS
                     (SELECT 1
                        FROM orders_temp b
                       WHERE A.order_id = b.order_id)) src
        ON (tgt.order_id = src.order_id)
    WHEN MATCHED
    THEN
      UPDATE SET tgt.status = src.status, tgt.price = src.price
         WHERE src.mask = 1
           AND tgt.status != src.status
           AND tgt.price != src.price
      DELETE
         WHERE src.mask = 0
    WHEN NOT MATCHED
    THEN
      INSERT VALUES (src.order_id, src.status, src.price)
    

    or you could try to use a full outer join and treat NULL values.
    G.

    Edited by: g. March 8, 2011 11:17

    changed to the Union all the

  • Windows Update has disappeared from the BONE. __

    I am using windows 7 32 bit.
    Windows Update gives me an error "Windows update does not work because the service is not running. Please try to restart the computer. When I open windows update by using the start menu, it takes about two minutes to open, then there is a red X beside where it says click to launch updates. When I click that is gives the above error.
    Also in my fix PC next to the clock. She has that I click so I can not change this setting either this "change window update.
    Seems that windows update has disappeared from the BONE.

    Hello

    Welcome to the Microsoft answers community site. I suggest you try these options:

    Option 1: Make sure that Windows Update Service is running, or if a force start it takes

    1. open run it and type services.msc, and then press ENTER.

    2 locate the underside of services in all install services list.

    Windows Update (a)

    (b) BITS (Background Intelligent Transfer Service)

    (c) cryptographic Services

    3. check that the status is started. If the condition column is blank, right-click on the service and select start.

    4. always make sure that the Startup Type is set to automatic, and then restart the computer.

    Option 2: How to reset the Windows Update components?

    Run the Microsoft Fixit tool to reset Windows Component Update.

    http://support.Microsoft.com/kb/971058

    See also http://windows.microsoft.com/en-US/windows-vista/Troubleshoot-problems-with-installing-updates

    Option 3: search for viruses and malware

    (A) online scanner to check if a virus is a cause of this problem. Follow the link to run a scan online http://onecare.live.com/site/en-au/default.htm?mkt=en-au

    Or use Microsoft Security Essentials - free

    http://www.Microsoft.com/Security_Essentials/

    (B) check for the shape of software malware malicious software removal tool

    http://www.Microsoft.com/security/malwareremove/default.mspx

    Or

    Follow the link below on how to get rid of malware: http://social.answers.microsoft.com/Forums/en-US/vistasecurity/thread/ba80504b-61f1-4d71-960f-b561798b7b42

    Let me know if it works. Good luck!

    Hope this information is useful.

    Thank you and best regards,

    KKS Vijay

    [If this post can help solve your problem, please click the 'Mark as answer' or 'Useful' at the top of this message.] [Marking a post as answer, or relatively useful, you help others find the answer more quickly.]

  • Why Microsoft did remove the ability for Windows Vista to install on herself from one location other than being inside the BONE you want to fix it?

    No Option to install repair - SAD

    Hello

    Why Microsoft removed the ability for Windows Vista to install on herself from one location other than being inside the BONE you want to repair.

    I recently had a problem where Vista Business 64-bit would only boot to a black screen with a mobile cursor - KSOD.   Who, in searching the Web I found is a fairly common problem with Vista.  I discovered that my only option was about to reinstall Vista CLEAN and all the other programs I had installed under it.  I can't believe that Microsoft released the 'repair installation option"similar to that of Windows XP, where you can hit the"R"key during installation and we left with nothing but the"System Restore"options and"Startup Repair ".  Neither of which has helped in my situation.  Since then, this was a dual system boot with XP Pro, then any restore point has been removed from the partition to Vista anytime, I started another recognized problem, by Microsoft, which Microsoft has made no significant effort to fix, in addition to recommending that you hide the partion Vista in XP - a whole of XP.  That beats a little the entire purpose of dual boot.

    As I tried to start in safe mode, it left me at the same point as a normal boot - black screen with a cursor.  I tried ctrl + alt + delete and nothing. Two Windows RE options did not help me.  This left me no option but to the completely reinstall Vista.   Why Microsoft did remove the ability for Windows Vista to install on herself from one location other than being inside the BONE you want to repair.. Please don't tell me that it is because Vista uses an image file instead of an installation as XP system.   I see no other reason for not allowing the upgrade of outside BONE in addition to Microsofts greed and paranoia that he can transform the operating system easier to install illegally.  I hope that some third party has actually changed the Vista installation routine to allow you to install Vista on itself, because as it is, it's really hard for me to even recommend Vista as the operating system or install any where else, if not the only recourse after loading OS, is to reinstall completely.

    Adobe, Autodesk, and almost all other software publishers... allow you to perform a "REPAIR" of their software installation, if something prevents you to load after installation.  Even MS Office has a routine repair.  Ms has an internal version of the Setup routine which allows outside the OS upgrade option that you want to "Upgrade" / repair? ".  If not, why?

    -Todd w.

    "Why Microsoft removed the ability for Windows Vista to install on herself from one location other than being inside the BONE you want to repair."

    «.. . After using XP's repair function, the operating system itself would become less stable and frankly not in a good state of repair. »

    As Todd, is the answer.

    "This response does not hold water as on one of my computers I've been running Windows XP for about four years now, after a repair install.

    Then, you were lucky.  Try to replace the system files on a computer that does not start even at a desk or safe mode usually will get a return to office, but will probably repeat the same problem in a few weeks.  Tech professional would only use this function to retrieve the data before a complete reinstallation.

    "I thought that this area was a place to really get answers instead of the ole same"answers of bs that are on all the other forums."

    It is a place that will try to help you fix your computer if you have problems.  It has technicians in computing, no decision-makers, developers or executives.  We will try to answer technical questions about problems you might have with Windows Vista.

    If you want to have input on the future of Microsoft operating systems, then help you beta-test and provide feedback to the developers.  Windows 7 and IE 8 are currently in beta.

    Another possible place you could make suggestions which could see the developers would be:

    https://connect.Microsoft.com/default.aspx

    Brent
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • When I insert my recovery disk its Blanck, but if I used the same disc in another computer I can see the content inside

    Original title: DVD RW drive

    I'm having a problem with my computer toshiba M645. When I insert my recovery disk its Blanck, but if I used the same disc in another computer I can see the contents inside. I try inserting the disk dvd movies and it will play normally. Please give me help with this problem because I want to get my phone to the sound out of the box state. Thank you.

    Hello

    The drive came with the laptop or you did it yourself in the recovery Partition?

    And you're supposed to boot from the recovery disc to start the recovery process.

    You change the Boot order to make the CD/DVD drive first in the boot order. Then, you start from the disc.

    How to change the Boot order in BIOS:

    http://pcsupport.about.com/od/fixtheproblem/SS/bootorderchange.htm

    And as a way to re - install with most of the Toshibas, you press 0 (zero) to start to start the process of recovery back to settings factory (new State) of the recovery Partition.

    See you soon.

  • What is the use of refresh after Update/Insert in Wizard EO?

    Hello!

    What is the use of refresh after Update/Insert in Wizard EO? When I need it and when not?

    Thank you.

    -These checkboxes are for columns whose values change after that db triggers run.

    BR, 906099

  • I allowed to CS2, I contact Adobe support for new link and new key for the new facility for the computer updated. In the installation, I have inserted the key from ADobe that I got Adobe support, but when I open programms CS2 it will not work and gives me

    I allowed to CS2, I contact Adobe support for new link and new key for the new facility for the computer updated. In the installation, I have inserted the key from ADobe that I got Adobe support, but when I opened any CS2 program it will not work and gives me the invalid key error. What should do?

    CS2: Error: unavailable activation server | CS2, Acrobat 7, hearing 3 -.

    l http://helpx.adobe.com/x-productkb/Policy-Pricing/Creative-Suite-2-activation-end-Life.htm

    https://helpx.Adobe.com/Creative-Suite/KB/CS2-product-downloads.html

Maybe you are looking for