Number of Rows Updated/Deleted/Inserted

Hi
To audit what rows inserted , deleted and updated in a particular table i am using the below code . However is there a way i can just get the count of rows inserted , updated and deleted based on date or user . Also please tell me how can i get the terminal and machine name of the USER.
PACKAGE:
CREATE OR REPLACE package audit_pkg
as
procedure check_val( l_tname in varchar2,
l_cname in varchar2,
l_new in varchar2,
l_old in varchar2 , action in varchar2);
procedure check_val( l_tname in varchar2,
l_cname in varchar2,
l_new in date,
l_old in date , action in varchar2);
procedure check_val( l_tname in varchar2,
l_cname in varchar2,
l_new in number,
l_old in number , action in varchar2 );
end;
PACKAGE BODY
CREATE OR REPLACE package audit_pkg
as
procedure check_val( l_tname in varchar2,
l_cname in varchar2,
l_new in varchar2,
l_old in varchar2 , action in varchar2);
procedure check_val( l_tname in varchar2,
l_cname in varchar2,
l_new in date,
l_old in date , action in varchar2);
procedure check_val( l_tname in varchar2,
l_cname in varchar2,
l_new in number,
l_old in number , action in varchar2 );
end;
TRIGGER :
/* Formatted on 2010/03/21 01:04 (Formatter Plus v4.8.8) */
CREATE OR REPLACE TRIGGER trigger_emp_up
AFTER UPDATE
ON emp
FOR EACH ROW
BEGIN
audit_pkg.check_val ('EMP', 'EMPNO', :NEW.empno, :OLD.empno, 'UPDATE' );
audit_pkg.check_val ('EMP', 'ENAME', :NEW.ename, :OLD.ename, 'UPDATE');
audit_pkg.check_val ('EMP', 'JOB', :NEW.job, :OLD.job, 'UPDATE');
audit_pkg.check_val ('EMP', 'MGR', :NEW.mgr, :OLD.mgr, 'UPDATE');
audit_pkg.check_val ('EMP', 'HIREDATE', :NEW.hiredate, :OLD.hiredate, 'UPDATE');
audit_pkg.check_val ('EMP', 'SAL', :NEW.sal, :OLD.sal, 'UPDATE');
audit_pkg.check_val ('EMP', 'COMM', :NEW.comm, :OLD.comm, 'UPDATE');
audit_pkg.check_val ('EMP', 'DEPTNO', :NEW.deptno, :OLD.deptno, 'UPDATE');
END;
/* Formatted on 2010/03/21 01:04 (Formatter Plus v4.8.8) */
CREATE OR REPLACE TRIGGER trigger_emp_in
AFTER INSERT
ON EMP
FOR EACH ROW
BEGIN
audit_pkg.check_val ('EMP', 'EMPNO', :NEW.empno, :OLD.empno, 'INSERT');
audit_pkg.check_val ('EMP', 'ENAME', :NEW.ename, :OLD.ename, 'INSERT');
audit_pkg.check_val ('EMP', 'JOB', :NEW.job, :OLD.job, 'INSERT');
audit_pkg.check_val ('EMP', 'MGR', :NEW.mgr, :OLD.mgr, 'INSERT');
audit_pkg.check_val ('EMP', 'HIREDATE', :NEW.hiredate, :OLD.hiredate, 'INSERT');
audit_pkg.check_val ('EMP', 'SAL', :NEW.sal, :OLD.sal, 'INSERT');
audit_pkg.check_val ('EMP', 'COMM', :NEW.comm, :OLD.comm, 'INSERT');
audit_pkg.check_val ('EMP', 'DEPTNO', :NEW.deptno, :OLD.deptno, 'INSERT');
END;
/* Formatted on 2010/03/21 01:03 (Formatter Plus v4.8.8) */
CREATE OR REPLACE TRIGGER trigger_emp_de
AFTER DELETE
ON EMP
FOR EACH ROW
BEGIN
audit_pkg.check_val ('EMP', 'EMPNO', :NEW.empno, :OLD.empno, 'DELETE');
--audit_pkg.check_val ('EMP', 'ENAME', :NEW.ename, :OLD.ename);
--audit_pkg.check_val ('EMP', 'JOB', :NEW.job, :OLD.job);
--audit_pkg.check_val ('EMP', 'MGR', :NEW.mgr, :OLD.mgr);
--audit_pkg.check_val ('EMP', 'HIREDATE', :NEW.hiredate, :OLD.hiredate);
--audit_pkg.check_val ('EMP', 'SAL', :NEW.sal, :OLD.sal);
--audit_pkg.check_val ('EMP', 'COMM', :NEW.comm, :OLD.comm);
--audit_pkg.check_val ('EMP', 'DEPTNO', :NEW.deptno, :OLD.deptno);
END;
Thanks

Hi
I'm not sure but i don't see that you are "auditing" time of the change and user to. You should expand your audit table ( and package )
with time and user atribut .
User , terminal , machine and much other things you can retrieve with sys_context function. For time you can use systimestamp function for example ..
http://www.psoug.org/reference/sys_context.html ( quite good reference )
For auditing things like machine you should be careful , if you are accesing your app through some http server you wil get the machine on which the server runs
and not the "client machine" from which the client has access the application throug that server .
T

Similar Messages

  • Rows updated and inserted by  MERGE

    Hi,
    Is there any way I can come to know, How many rows are updated and inserted using a MERGE statement.
    Thanks in advance

    Something like this ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>
    satyaki>
    satyaki>desc aud_emp;
    Name                                      Null?    Type
    EMPNO                                              NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                             NUMBER(2)
    AUDIT_TMP                                          TIMESTAMP(6)
    AUDIT_IP_ADDR                                      VARCHAR2(15)
    OPR_DESC                                           VARCHAR2(30)
    USER_NM                                            VARCHAR2(40)
    REMARKS                                            VARCHAR2(200)
    satyaki>
    satyaki>
    satyaki>
    satyaki>
    satyaki>select * from aud_emp;
    no rows selected
    Elapsed: 00:00:00.04
    satyaki>
    satyaki>
    satyaki>select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    13 rows selected.
    Elapsed: 00:00:00.01
    satyaki>
    satyaki>select * from e_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7566 JONES      MANAGER         7839 02-APR-81    3718.75                    20
          7782 CLARK      MANAGER         7839 09-JUN-81     3062.5                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82      11700                    10
    7 rows selected.
    Elapsed: 00:00:00.07
    satyaki>CREATE OR REPLACE TRIGGER trg_aud
    before insert or update or delete on e_emp
    for each row
    declare
         S_IP_ADDR    varchar2(30);
         str          varchar2(320);
         s_empno      varchar2(40);
         s_ename      varchar2(40);
         s_job        varchar2(40);
         s_mgr        varchar2(40);
         s_hrdate     varchar2(40);
         s_sal        varchar2(40);
         s_comm       varchar2(40);
         s_deptno     varchar2(40);
    begin
         SELECT SYS_CONTEXT('USERENV','IP_ADDRESS')
         into S_IP_ADDR
         from dual;
         str:= null;
         if inserting then
             insert into aud_emp values(:new.empno,
                                        :new.ename,
                                        :new.job,
                                        :new.mgr,
                                        :new.hiredate,
                                        :new.sal,
                                        :new.comm,
                                        :new.deptno,
                                        systimestamp,
                                        S_IP_ADDR,
                                        'INSERT',
                                        USER,
                                        NULL);
         elsif updating then
           if :old.empno <> :new.empno then
              s_empno := 'Employee No: '||:old.empno;
           elsif :old.ename <> :new.ename then
              s_ename := 'Employee Name: '||:old.ename;
           elsif :old.job <> :new.job then
              s_job := 'Job: '||:old.job;
           elsif :old.mgr <> :new.mgr then
              s_mgr := 'Mgr: '||:old.mgr;
           elsif :old.hiredate <> :new.hiredate then
              s_hrdate := 'Hire Date: '||:old.hiredate;
           elsif :old.sal <> :new.sal then
              s_sal := 'Salary: '||:old.sal;
           elsif :old.comm <> :new.comm then
              s_comm := 'Commission: '||:old.comm;
           elsif :old.deptno <> :new.deptno then
              s_deptno := 'Department No: '||:old.deptno;
           end if;
           str:= 'Updated Records Details -> '||s_empno||' '||s_ename||' '||s_job||' '||s_mgr||' '||s_hrdate||' '||s_sal||' '||s_comm||' '||s_deptno;
             insert into aud_emp values(:new.empno,
                                        :new.ename,
                                        :new.job,
                                        :new.mgr,
                                        :new.hiredate,
                                        :new.sal,
                                        :new.comm,
                                        :new.deptno,
                                        systimestamp,
                                        S_IP_ADDR,
                                        'UPDATE',
                                        USER,
                                        str);
         elsif deleting then
             insert into aud_emp values(:old.empno,
                                        :old.ename,
                                        :old.job,
                                        :old.mgr,
                                        :old.hiredate,
                                        :old.sal,
                                        :old.comm,
                                        :old.deptno,
                                        systimestamp,
                                        S_IP_ADDR,
                                        'DELETE',
                                        USER,
                                        'Old Records before deletion');
         end if;
    exception
        when others then
          raise_application_error(-20501,'Contact With Your Admin....');
    end;
    Trigger Created.
    Elapsed: 00:00:00.09
    satyaki>ed
    Wrote file afiedt.buf
      1  merge into e_emp o
      2     using emp n
      3     on ( o.empno = n.empno)
      4     when matched then
      5       update set o.ename = n.ename,
      6                  o.job   = n.job,
      7                  o.mgr   = n.mgr,
      8                  o.hiredate = n.hiredate,
      9                  o.sal = n.sal,
    10                  o.comm = n.comm,
    11                  o.deptno = n.deptno
    12     when not matched then
    13       insert( o.empno,
    14               o.ename,
    15               o.job,
    16               o.mgr,
    17               o.hiredate,
    18               o.sal,
    19               o.comm,
    20               o.deptno)
    21       values( n.empno,
    22               n.ename,
    23               n.job,
    24               n.mgr,
    25               n.hiredate,
    26               n.sal,
    27               n.comm,
    28*              n.deptno)
    satyaki>/
    13 rows merged.
    Elapsed: 00:00:03.95
    satyaki>
    satyaki>commit;
    Commit complete.
    Elapsed: 00:00:00.07
    satyaki>
    satyaki>
    satyaki>select * from aud_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO AUDIT_TMP                                                                   AUDIT_IP_ADDR   OPR_DESC                       USER_NM                                  REMARKS
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20 31-DEC-08 10.54.06.667000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->      Salary: 3718.75
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10 31-DEC-08 10.54.06.686000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->      Salary: 3062.5
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20 31-DEC-08 10.54.06.687000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->
          7839 KING       PRESIDENT            17-NOV-81       7000                    10 31-DEC-08 10.54.06.697000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->      Salary: 5000
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20 31-DEC-08 10.54.06.698000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20 31-DEC-08 10.54.06.699000 PM                                                10.23.99.77     UPDATE                         SCOTT                                    Updated Records Details ->
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30 31-DEC-08 10.54.06.720000 PM                                                10.23.99.77     INSERT                         SCOTT
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10 31-DEC-08 10.54.07.059000 PM                                                10.23.99.77     INSERT                         SCOTT
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30 31-DEC-08 10.54.07.060000 PM                                                10.23.99.77     INSERT                         SCOTT
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30 31-DEC-08 10.54.07.060000 PM                                                10.23.99.77     INSERT                         SCOTT
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30 31-DEC-08 10.54.07.061000 PM                                                10.23.99.77     INSERT                         SCOTT
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO AUDIT_TMP                                                                   AUDIT_IP_ADDR   OPR_DESC                       USER_NM                                  REMARKS
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10 31-DEC-08 10.54.07.061000 PM                                                10.23.99.77     INSERT                         SCOTT
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30 31-DEC-08 10.54.07.062000 PM                                                10.23.99.77     INSERT                         SCOTT
    13 rows selected.
    Elapsed: 00:00:00.22
    satyaki>
    satyaki>set lin 80Hope this will help you.
    Regards.
    Satyaki De.

  • Best approach to Update / Delete / Insert

    Hi Guys
    I was flicking through my HTML DB Oracle University course notes the other day and was reading about onSubmit processes that are carried out after page submission / computations and validations.
    The example cited was for an insert statement using form items.
    At the bottom there was a warning that this approach should not be used for Updates / Deletes. Why is this?
    I have a custom built form that inserts into 3 tables so the out of the box functionality of HTML DB will not suffice. Instead i created an onSubmit processes that performs the inserts using many of the form items and a few sequences etc.
    This works fine but I also have to do a similar form for updates across many tables based on the users input.
    I was just curious why you should not use an onSubmit process to do updates / deletes? and any best practices that I should be adhering to.
    Cheers for any help
    Duncan

    Hello Duncan,
    I believe the warning is not about using what you call onSubmit processes, but how to use them in case of update and delete.
    When you are inserting a new data into a table, you don't really need to care about what is going on with the other users of the application. This is not the case when you update or delete a record. Prior to doing that you must verify that other users do not rely on that record in their processes. If they are, you must deal with that. If you are using the built in Automatic DML process it's doing it for you. If you are coding it manually, you must do it yourself.
    You should search for "lost update" or "optimistic lock" to learn more about this.
    Regards,
    Arie.

  • How to update first N number of rows updated

    UPDATE cc_claiminfo SET state = 2 WHERE state = 1
    Is it possible to make it so that only the first some number of rows (say 10,000) is updated?
    What is the proper way to do this?

    WHERE rownum < 10001
    Although which 10,000 rows will be updated is
    impossible to predict in advance.
    UPDATE (select ... from cc_claiminfo
                   where ...
                   order by ...
    where rownum > 10001Message was edited by:
    Dave Hemming
    (I just got asked this question myself by a colleague, so searched for the answer because my brain wasn't in gear. It got in gear once I saw this)

  • I want to know number of rows updated by my query

    I want to know how many rows have been updated caused by an update query?. Does any database variable can tell me that ?

    PreparedStatment pstmt = conn.prepareStatement("my updated query");
    pstmt.setXXX
    int rowsupdated = pstmt.executeUpdate();
    rowsupdated = no of rows updated by the statement executed by this prepared statement.
    Elango.

  • How can i display recent update/delete/insert records in form

    Hai !!!!
    i am new for forms,.......any body tell me, how can i display recent no of records updated or no of records deleted or no of records are inserted in a form. these records count are display in display items....give me detail explination......
    Subbu.....

    the easiest way is copy and paste the oracle-forms example from the OU.
    You need form-level-trigger ON-ERROR + ON-MESSAGE, POST-INSERT, POST-UPDATE, POST-DELETE, three global variables and a procedure:
    ON-ERROR
    handle_message( error_code, 'ERROR: ' || ERROR_TYPE || '-' || TO_CHAR(ERROR_CODE) ||': '|| ERROR_TEXT );
    ON-MESSAGE
    handle_message( message_code, MESSAGE_TYPE || '-' || TO_CHAR(MESSAGE_CODE) || ': ' || MESSAGE_TEXT );
    PROCEDURE handle_message( message_number IN NUMBER, message_line IN VARCHAR2 ) IS
    BEGIN
        IF message_number IN ( 40400, 40406, 40407 )
        THEN
          DEFAULT_VALUE( '0', 'GLOBAL.insert' );
          DEFAULT_VALUE( '0', 'GLOBAL.update' );
          DEFAULT_VALUE( '0', 'GLOBAL.delete' );
          MESSAGE('Save Ok: ' ||
            :GLOBAL.insert || ' records inserted, ' ||
           :GLOBAL.update || ' records updated, ' ||
           :GLOBAL.delete || ' records deleted !!!' );
          ERASE('GLOBAL.insert'); 
          ERASE('GLOBAL.update');
          ERASE('GLOBAL.delete');
        ELSE
             MESSAGE(message_line );
              END IF;
    END;
    POST-INSERT
    DEFAULT_VALUE('0', 'GLOBAL.insert');
    :GLOBAL.insert := TO_CHAR( TO_NUMBER( :GLOBAL.insert ) + 1 );
    POST-UPDATE
    DEFAULT_VALUE('0', 'GLOBAL.update');
    :GLOBAL.update := TO_CHAR( TO_NUMBER( :GLOBAL.update ) + 1 );
    POST-DELETE
    DEFAULT_VALUE('0', 'GLOBAL.delete');
    :GLOBAL.delete := TO_CHAR( TO_NUMBER( :GLOBAL.delete ) + 1 );try it
    Gerd

  • Need to perform multi-row update/delete

    Gday,
    I have a request to have one update button for a multi-row form. Also needed will be a checkbox as part of the row.
    The check boxes only purpose is to signify the record should be deleted. Thus I am assuming I cannot use default
    apex functionality and must manually build the multi-row form. I guess I would loop through and check to see if a
    record is checked delete otherwise loop through and update all columns for that record? I am assuming I should
    use the examples in http://www.oracle.com/technology/products/database/application_express/howtos/tabular_form.html
    is that all still valid for apex 3.2.1?
    Cheers

    Hello:
    You could also do the following
    Generate the tabular form page using the wizard
    Delete or not display the 'Delete' button
    Delete or not execute the 'ApplyMRD' process
    Create a new page process with a sequence higher than the standard MRU processes. Make this process conditional on the 'Submit' button. Use code similar to the one below for this page processfor i in 1..apex_application.g_f01.count loop   --- f01 is the selector checbox, f02 is the hidden column with the table's PK
      delete from emp where empno=apex_application.g_f02(apex_application.g_f01(i));
    end loop;Now, when you click 'Submit' records with their selector checkbox checked will be deleted by the newly added page process. The rest of the functionality of the tabular form remains the same.
    varad

  • Query returning different number of rows standalone vs insert statement

    Hi,
    We are using Oracle 10g. We are facing a issue where a SELECT inserts 26294 rows when used with a insert statement. The same select (cut-and-paste) when executed standalone, returns only 60 rows. Any idea what could be causing this?
    Thanks in advance,
    Hari Narayanan
    TIAA-CREF
    See details below,
    SQL> INSERT INTO cref.position_recon_breaks (
    2 effective_date,
    3 fund_entity_id,
    4 security_alias,
    5 accounting_system,
    6 pace_shares,
    7 accounting_sys_shares,
    8 accounting_sys_unp_trd_shares
    9 )
    10 SELECT pr.effective_date,
    11 pr.ENTITY_ID,
    12 pr.SECURITY_ALIAS,
    13 'MELLON',
    14 CREF_SHARES PACE_SHARES,
    15 CORP_SHARES ACCOUNTING_SYS_SHARES,
    16 CORP_UNP_TRD_SHARES ACCOUNTING_SYS_UNP_TRD_SHARES
    17 FROM cref.MELLON_POSITION_RECON pr
    18 WHERE ABS(SHARES_DIFFERENCE) >= 1;
    25294 rows created.
    SQL> select count(*) from
    2 (SELECT pr.effective_date,
    3 pr.ENTITY_ID,
    4 pr.SECURITY_ALIAS,
    5 'MELLON',
    6 CREF_SHARES PACE_SHARES,
    7 CORP_SHARES ACCOUNTING_SYS_SHARES,
    8 CORP_UNP_TRD_SHARES ACCOUNTING_SYS_UNP_TRD_SHARES
    9 FROM cref.MELLON_POSITION_RECON pr
    10 WHERE ABS(SHARES_DIFFERENCE) >= 1);
    COUNT(*)
    60

    charred/jzhang,
    Thanks for your responses. Just as an additional info, MELLON_POSITION_RECON is one hell of a view - not written by me :) - with unions and inline queries.
    If it would be of any help, here is the script,
    CREATE OR REPLACE FORCE VIEW CREF.MELLON_POSITION_RECON
    (EFFECTIVE_DATE, FUND_CODE, ENTITY_ID, ENTITY_NAME, SECURITY_ALIAS,
    SECURITY_NAME, PRIMARY_ASSET_ID, CREF_SECURITY_COUNT, CORP_SECURITY_COUNT, CREF_CURRENCY_CODE,
    CORP_CURRENCY_CODE, CREF_EXCHANGE_RATE, CORP_EXCHANGE_RATE, CREF_SHARES, CORP_SHARES,
    CREF_PRICE_LOCAL, CORP_PRICE_LOCAL, CREF_MARKET_VALUE_USD, CORP_MARKET_VALUE_USD, CREF_MARKET_VALUE_LOCAL,
    CORP_MARKET_VALUE_LOCAL, CREF_ACCRUED_INCOME_USD, CORP_ACCRUED_INCOME_USD, CORP_UNP_TRD_MARKET_VALUE, CORP_UNP_TRD_SHARES,
    SHARES_DIFFERENCE, SHARES_DIFF_INCL_UNP, LOCAL_PRICE_DIFFERENCE, MKT_VALUE_USD_DIFF, MKT_VALUE_USD_DIFF_INCL_UNP,
    ACCRUED_INCOME_DIFF)
    AS
    SELECT /*+ ORDERED */
    P.EFFECTIVE_DATE
    ,E.CODE FUND_CODE
    ,P.ENTITY_ID
    ,E.LONG_NAME ENTITY_NAME
    ,P.SECURITY_ALIAS
    ,S.ISSUE_NAME SECURITY_NAME
    ,S.PRIMARY_ASSET_ID
    ,P.CREF_SECURITY_COUNT
    ,P.CORP_SECURITY_COUNT CORP_SECURITY_COUNT
    ,P.CREF_CURRENCY_CODE
    ,P.CORP_CURRENCY_CODE CORP_CURRENCY_CODE
    ,P.CREF_EXCHANGE_RATE
    ,P.CORP_EXCHANGE_RATE CORP_EXCHANGE_RATE
    ,P.CREF_SHARES
    ,P.CORP_SHARES CORP_SHARES
    ,P.CREF_PRICE_LOCAL
    ,P.CORP_PRICE_LOCAL CORP_PRICE_LOCAL
    ,ROUND(P.CREF_MARKET_VALUE_USD,2) CREF_MARKET_VALUE_USD
    ,P.CORP_MARKET_VALUE_USD CORP_MARKET_VALUE_USD
    ,ROUND(P.CREF_MARKET_VALUE_LOCAL,2) CREF_MARKET_VALUE_LOCAL
    ,P.CORP_MARKET_VALUE_LOCAL CORP_MARKET_VALUE_LOCAL
    ,ROUND(P.CREF_ACCRUED_INCOME_USD,2) CREF_ACCRUED_INCOME_USD
    ,P.CORP_ACCRUED_INCOME_USD
    ,P.CORP_UNP_TRD_MARKET_VALUE
    ,P.CORP_UNP_TRD_SHARES
    ,NVL(P.CORP_SHARES, 0) - NVL(P.CREF_SHARES, 0) SHARES_DIFFERENCE
    ,NVL(P.CORP_SHARES,0) +
    (NVL(P.CORP_UNP_TRD_SHARES, 0) - NVL(P.CREF_SHARES, 0)) SHARES_DIFF_INCL_UNP
    ,NVL(P.CREF_PRICE_LOCAL, 0) - NVL(P.CORP_PRICE_LOCAL, 0) LOCAL_PRICE_DIFFERENCE
    ,NVL(ROUND(P.CREF_MARKET_VALUE_USD,2),0) - NVL(P.CORP_MARKET_VALUE_USD,0) MKT_VALUE_USD_DIFF
    ,NVL(ROUND(P.CREF_MARKET_VALUE_USD,2),0) -
    (NVL(P.CORP_MARKET_VALUE_USD, 0) + NVL(P.CORP_UNP_TRD_MARKET_VALUE,0)) MKT_VALUE_USD_DIFF_INCL_UNP
    ,NVL(ROUND(P.CREF_ACCRUED_INCOME_USD,2),0) - NVL(P.CORP_ACCRUED_INCOME_USD, 0) ACCRUED_INCOME_DIFF
    FROM
    SELECT ENTITY_ID
    ,EFFECTIVE_DATE
    ,SECURITY_ALIAS
    ,SUM(CREF_SECURITY_COUNT) CREF_SECURITY_COUNT
    ,SUM(CORP_SECURITY_COUNT) CORP_SECURITY_COUNT
    ,MAX(CREF_CURRENCY_CODE) CREF_CURRENCY_CODE
    ,MAX(CORP_CURRENCY_CODE) CORP_CURRENCY_CODE
    ,MAX(CREF_EXCHANGE_RATE) CREF_EXCHANGE_RATE
    ,MAX(CORP_EXCHANGE_RATE) CORP_EXCHANGE_RATE
    ,SUM(CREF_SHARES) CREF_SHARES
    ,SUM(CORP_SHARES) CORP_SHARES
    ,MAX(CREF_PRICE_LOCAL) CREF_PRICE_LOCAL
    ,MAX(CORP_PRICE_LOCAL) CORP_PRICE_LOCAL
    ,SUM(CREF_MARKET_VALUE_USD) CREF_MARKET_VALUE_USD
    ,SUM(CORP_MARKET_VALUE_USD) CORP_MARKET_VALUE_USD
    ,SUM(CREF_MARKET_VALUE_LOCAL) CREF_MARKET_VALUE_LOCAL
    ,SUM(CORP_MARKET_VALUE_LOCAL) CORP_MARKET_VALUE_LOCAL
    ,SUM(CREF_ACCRUED_INCOME_USD) CREF_ACCRUED_INCOME_USD
    ,SUM(CORP_ACCRUED_INCOME_USD) CORP_ACCRUED_INCOME_USD
    ,MIN(QUERY_TIMESTAMP) QUERY_TIMESTAMP
    ,SUM(CORP_UNP_TRD_MARKET_VALUE) CORP_UNP_TRD_MARKET_VALUE
    ,SUM(CORP_UNP_TRD_SHARES) CORP_UNP_TRD_SHARES
    FROM
    SELECT -- WANT ONE ROW PER FUND PER SECURITY
    /*+ index(p I_POS_ENTID_SRCINTFC_CREF) index (pd) */
    E.FUND_ENTITY_ID ENTITY_ID
    ,P.EFFECTIVE_DATE
    ,PD.SECURITY_ALIAS
    ,SYSDATE QUERY_TIMESTAMP
    ,1 CREF_SECURITY_COUNT
    ,MAX(PD.LOCAL_CURRENCY) CREF_CURRENCY_CODE
    ,MAX(PD.MKT_EXCHANGE_RATE) CREF_EXCHANGE_RATE
    ,SUM(PD.SHARE_PAR_VALUE) CREF_SHARES
    ,MAX(PD.PRICE) CREF_PRICE_LOCAL
    ,SUM(PD.MARKET_VALUE) CREF_MARKET_VALUE_USD
    ,SUM(PD.LOCAL_MARKET_VALUE) CREF_MARKET_VALUE_LOCAL
    ,SUM(PD.ACCRUED_INCOME) CREF_ACCRUED_INCOME_USD
    ,0 CORP_SECURITY_COUNT
    ,TO_CHAR(NULL) CORP_CURRENCY_CODE
    ,0 CORP_SHARES
    ,TO_NUMBER(NULL) CORP_PRICE_LOCAL
    ,TO_NUMBER(NULL) CORP_EXCHANGE_RATE
    ,0 CORP_MARKET_VALUE_USD
    ,0 CORP_MARKET_VALUE_LOCAL
    ,0 CORP_ACCRUED_INCOME_USD
    ,0 CORP_UNP_TRD_MARKET_VALUE
    ,0 CORP_UNP_TRD_SHARES
    FROM CREF.ENTITY E,
    CREF.ENTITY EF                fund entity       NF
    ,HOLDINGDBO.POSITION P
    ,(SELECT MAX(EFFECTIVE_DATE) CURRENT_DATE
    FROM HOLDINGDBO.POSITION P,
    PACE_MASTERDBO.INTERFACES I
    WHERE I.SHORT_DESC = 'MELLON'
    AND I.INSTANCE = P.SRC_INTFC_INST) DT
    ,HOLDINGDBO.POSITION_DETAIL PD
    ,PACE_MASTERDBO.INTERFACES I
    WHERE E.PORTFOLIO_ENTITY_TYPE_CODE = 'PORT'
    AND E.ENTITY_ID = P.ENTITY_ID
    AND EF.ENTITY_ID = E.FUND_ENTITY_ID           -- NF
    AND EF.ACCOUNTING_SYSTEM = 'MELLON'      -- NF
    AND E.ENTITY_ID = P.ENTITY_ID
    AND I.SHORT_DESC = 'STARDIRECT'
    AND I.INSTANCE = P.SRC_INTFC_INST
    AND P.EFFECTIVE_DATE = DT.CURRENT_DATE
    AND P.POSITION_ID = PD.POSITION_ID
    -- "GROUP BY" COMBINES THE LONG AND SHORT POSITIONS
    GROUP BY P.EFFECTIVE_DATE, E.FUND_ENTITY_ID, PD.SECURITY_ALIAS
    UNION ALL
    SELECT -- CORPORATE SENDS ONE ROW PER FUND PER SECURITY (NO SHORTS)
    /*+ index(p I_POS_ENTID_SRCINTFC_CREF) index (pd) */
    E.ENTITY_ID
    ,P.EFFECTIVE_DATE
    ,PD.SECURITY_ALIAS
    ,SYSDATE QUERY_TIMESTAMP
    ,0 CREF_SECURITY_COUNT
    ,TO_CHAR(NULL) CREF_CURRENCY_CODE
    ,0 CREF_SHARES
    ,TO_NUMBER(NULL) CREF_PRICE_LOCAL
    ,TO_NUMBER(NULL) CREF_EXCHANGE_RATE
    ,0 CREF_MARKET_VALUE_USD
    ,0 CREF_MARKET_VALUE_LOCAL
    ,0 CREF_ACCRUED_INCOME_USD
    ,1 CORP_SECURITY_COUNT
    ,PD.LOCAL_CURRENCY CORP_CURRENCY_CODE
    ,PD.SHARE_PAR_VALUE CORP_SHARES
    ,PD.PRICE CORP_PRICE_LOCAL
    ,pd.mkt_exchange_rate CORP_EXCHANGE_RATE
    ,PD.MARKET_VALUE CORP_MARKET_VALUE_USD
    ,PD.LOCAL_MARKET_VALUE CORP_MARKET_VALUE_LOCAL
    ,PD.ACCRUED_INCOME CORP_ACCRUED_INCOME_USD
    ,0 CORP_UNP_TRD_MARKET_VALUE
    ,0 CORP_UNP_TRD_SHARES
    FROM CREF.ENTITY E
    ,HOLDINGDBO.POSITION P
    ,(SELECT MAX(EFFECTIVE_DATE) CURRENT_DATE
    FROM HOLDINGDBO.POSITION P,
    PACE_MASTERDBO.INTERFACES I
    WHERE I.SHORT_DESC = 'MELLON'
    AND I.INSTANCE = P.SRC_INTFC_INST) DT
    ,HOLDINGDBO.POSITION_DETAIL PD
    ,PACE_MASTERDBO.INTERFACES I
    WHERE E.FUND_FLAG = 'Y' --
    AND E.ENTITY_ID = P.ENTITY_ID
    AND I.SHORT_DESC = 'MELLON'
    AND I.INSTANCE = P.SRC_INTFC_INST
    AND P.EFFECTIVE_DATE = DT.CURRENT_DATE
    AND P.POSITION_ID = PD.POSITION_ID
    UNION ALL
    SELECT
    UTS.FUND_ENTITY_ID ENTITY_ID
    ,UTS.EFFECTIVE_DATE
    ,UTS.SECURITY_ALIAS
    ,SYSDATE QUERY_TIMESTAMP
    ,0 CREF_SECURITY_COUNT
    ,TO_CHAR(NULL) CREF_CURRENCY_CODE
    ,0 CREF_SHARES
    ,TO_NUMBER(NULL) CREF_PRICE_LOCAL
    ,TO_NUMBER(NULL) CREF_EXCHANGE_RATE
    ,0 CREF_MARKET_VALUE_USD
    ,0 CREF_MARKET_VALUE_LOCAL
    ,0 CREF_ACCRUED_INCOME_USD
    ,0 CORP_SECURITY_COUNT
    ,TO_CHAR(NULL) CORP_CURRENCY_CODE
    ,0 CORP_SHARES
    ,TO_NUMBER(NULL) CORP_PRICE_LOCAL
    ,TO_NUMBER(NULL) CORP_EXCHANGE_RATE
    ,0 CORP_MARKET_VALUE_USD
    ,0 CORP_MARKET_VALUE_LOCAL
    ,0 CORP_ACCRUED_INCOME_USD
    ,UTS.SUM_MARKET_VALUE CORP_UNP_TRD_MARKET_VALUE
    ,UTS.SUM_SHARES CORP_UNP_TRD_SHARES
    FROM
    (SELECT MAX(EFFECTIVE_DATE) CURRENT_DATE
    FROM HOLDINGDBO.POSITION P,
    PACE_MASTERDBO.INTERFACES I
    WHERE I.SHORT_DESC = 'MELLON'
    AND I.INSTANCE = P.SRC_INTFC_INST) DT
    ,cref.UNPROCESSED_TRADES_SUM UTS
    WHERE DT.CURRENT_DATE = UTS.EFFECTIVE_DATE
    AND UTS.UPDATED_BY = 'MELLON'
    GROUP BY EFFECTIVE_DATE, ENTITY_ID, SECURITY_ALIAS
    ) P,
    cref.ENTITY E,
    SECURITYDBO.SECMASTER_HISTORY S
    WHERE P.ENTITY_ID = E.ENTITY_ID
    AND P.SECURITY_ALIAS = S.SECURITY_ALIAS
    AND S.SRC_INTFC_INST = (SELECT INSTANCE FROM PACE_MASTERDBO.INTERFACES
    WHERE SHORT_DESC = 'EAGLE PACE')
    AND S.EFFECTIVE_DATE = (SELECT MAX(S1.EFFECTIVE_DATE)
    FROM SECURITYDBO.SECMASTER_HISTORY S1
    WHERE S1.SRC_INTFC_INST = S.SRC_INTFC_INST
    AND S1.SECURITY_ALIAS = S.SECURITY_ALIAS
    AND S1.EFFECTIVE_DATE <= P.EFFECTIVE_DATE);

  • Multi-Row insert/update/delete not working via db-link

    App. Version: 2.0.0.00.49
    DB: Oracle 9i, not sure about the build
    Problem: Multirow Update/Insert/Delete doesn't work via db-link.
    Error received: ....ORA-1460: unimplemented or unreasonable conversion requested....
    Where: Tabular Form generated via Wizard
    Side note: It's working properly when local table(s) is/are used, it's not working via db-link or view.
    I've encountered this error with single update/insert/delete operations before, but was able to fix it via using temp-variables (v_xyz := :Px_xyz; as the proposed v('Px_xyz') was really slow with my scripts)...but with the automated DML-action I don't see a way to edit it accordingly.
    Workaround found:
    1a) Use local* collection on HTML-DB-Server, then write single row updates/deletes/inserts to the remote DB via DB-Link
    1b) Use local* table on HTML-DB-Server, then write single row updates/deletes/inserts to the remote DB via DB-Link
    * Local = on the same server that HTML-DB is running on...
    So,...to my questions:
    1. Can someone confirm that this is a "known feature" (aka bug)?
    2. Can someone tell me if this "known feature" has been eliminated in the newer version of HTML-DB/APEX (> 2.0.0.00.49)?
    Thanks.
    Ingo

    Hi,
    Do you have a small test case program that demonstrates this? A JDeveloper project showing what exactly is the problem when trying to use the BDB SQL JDBC driver to insert data into the BDB SQL database? What do you mean by "not working", do you get any errors, you do not get errors but you do not see the data in the database etc?
    What are the versions of Java, JDeveloper, ADF and BDB SQL you are using, and on what OS?
    Regards,
    Andrei

  • Count of Rows Updated with prepared statement batch

    I am using a batch of prepared statements for update operation. (pstmt.executeBatch())
    Configuration I am using
    WLS 6.1sp2 Connection pool - Oracle Thin driver - TX Datasource
    DB - Oracle 8.1.7
    The batch update works well i.e data gets updated and committed. BUT I am not
    getting back the count of number of rows updated.
    Is there any thing more required on WLS side ?
    Thanks in Advance

    The Oracle drivers do not return the updated row counts from batched updates.
    Try running the attached program with the thin driver
    java Batch oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:@host:port:database user password
    You will see that returns -2, which indicates that the number of rows updated is unknown.
    This does meet the JDBC spec.
    "Harshad Nanal" <[email protected]> wrote in message news:3f8a455f$[email protected]..
    >
    I am using a batch of prepared statements for update operation. (pstmt.executeBatch())
    Configuration I am using
    WLS 6.1sp2 Connection pool - Oracle Thin driver - TX Datasource
    DB - Oracle 8.1.7
    The batch update works well i.e data gets updated and committed. BUT I am not
    getting back the count of number of rows updated.
    Is there any thing more required on WLS side ?
    Thanks in Advance[Batch.java]

  • Auditing number of rows Insert/Update/Delete

    Hi,
    We have turn on auditing on our database (audit=db), but we don't know where to find the numbe of rows processed by each DML.
    Does anyone have an idea ?
    Thank's
    Regard.
    Edited by: user5774759 on Sep 14, 2011 2:50 AM

    To check all the DML statements you have to set the Fine-grained-auditting(FGA) .
    For you have to set the triggered against the statements .
    http://vishwanath-dbahelp.blogspot.com/2011/09/setting-fga-at-schema-level.html
    let me know if u face any problem .
    Hope this help you :)
    --neeraj                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to Display Number of Rows Deleted/Inserted etc... in PL/SQL

    In Oracle 10g PL/SQL, I have a delete statement in a stored procedure. It is not in a cursor. I want to see the number of rows I've deleted. I can use the dbms_output.put_line package. I should know this, but I don't have time to perfect the syntax. How would I get the number of rows that get deleted and display it via dbms_output.put_lline?

    No time to google either I guess.
    http://www.google.co.uk/search?q=number+of+rows+deleted+oracle&rls=com.microsoft:en-gb&ie=UTF-8&oe=UTF-8&startIndex=&startPage=1&rlz=&redir_esc=&ei=Qi5qToGyGYqw8QOGzf3nAg
    SQL> create table dt_del_ex(id number);
    Table created.
    SQL> set serveroutput on
    SQL> BEGIN
      2
      3      INSERT INTO dt_del_ex VALUES(1);
      4
      5      DBMS_OUTPUT.put_line(TO_CHAR(SQL%ROWCOUNT)||' rows inserted');
      6
      7      INSERT INTO dt_del_ex select rownum from dual connect by level <=10;
      8
      9      DBMS_OUTPUT.put_line(TO_CHAR(SQL%ROWCOUNT)||' rows inserted');
    10
    11      UPDATE dt_del_ex SET id = id + 3 WHERE id >= 9;
    12
    13      DBMS_OUTPUT.put_line(TO_CHAR(SQL%ROWCOUNT)||' rows updated');
    14
    15      DELETE FROM dt_del_ex WHERE id <= 10;
    16
    17      DBMS_OUTPUT.put_line(TO_CHAR(SQL%ROWCOUNT)||' rows deleted');
    18
    19  END;
    20  /
    1 rows inserted
    10 rows inserted
    2 rows updated
    9 rows deleted
    PL/SQL procedure successfully completed.

  • I want a user to only be able to update/delete the rows they inserted

    hi guys,
    I have a table 2 users are inserting into. They can also update/delete the rows in the table. However, I do not want them to be able to update/delete the others users row. I only want them to have update/delete at the row level.
    how can this be achieved?
    thanks

    Another idea if you really have just two (or a fixed set of N) users.
    Does your table have a generic primary key (PK)?
    You could use two (N) sequences having two (N) distinct sets of numbers as e.g user a is using sequences less than 1000000000, the other one values larger or equal to 1000000000.
    create sequence <user_a>.pk_seq start with 0;
    create sequence <user_b>.pk_seq start with 1000000000;An insert trigger uses <user_a>.pk_seq or <user_b>.pk_seq for generating the PK depending upon the current user for new records.
    An update trigger allows updates only, if the PK of the record to be updated is in the range of sequences belonging to the current user.

  • How to display the result of  excutions(insert/update/delete rows)

    Hello.
    Does anyone know how to display the result of scenario executions just like a scenario executions tab of package (insert/update/delete rows) in other screen (in the intergated operating platform for operators using http)
    In additional, I also like to show the hierarchy of scenario in the same view.
    So, I need the query using the information of the ODI repository.
    If it is possible, I also like to have the decription of the tables in the ODI repository.
    Can anyone tell me how can I get the information of the counts of excution?
    Thanks in advance.

    Hi,
    You can get that information from the API getPrevStepLog. Does it work for you?
    Download the last API reference manual from:
    http://www.oracle.com/technology/products/oracle-data-integrator/10.1.3/htdocs/1013_support.html#docs

  • How to get last insert/update/delet row of a table?

    I hava a table A and table B which is a copy of A. I want to create a trigger to record the changes of A in B. So every time inserting/updating/deleting A I record the row inserted/updated/deleted in B, But I can't find a effiencial way to get the latest row changed.
    So is there any sys_var in oracle table like cur_rowid or something to record the latest inserted/updated/deleted in a table? I don't want to check a index or a table to get the max_seq_id again.

    user11228816 wrote:
    I hava a table A and table B which is a copy of A. I want to create a trigger to record the changes of A in B. So every time inserting/updating/deleting A I record the row inserted/updated/deleted in B, But I can't find a effiencial way to get the latest row changed.
    So is there any sys_var in oracle table like cur_rowid or something to record the latest inserted/updated/deleted in a table? I don't want to check a index or a table to get the max_seq_id again.Sounds like an ugly requirement, any reason you're not going for materialized views or advanced replication here?

Maybe you are looking for

  • Netflix streaming affects network ping

    I know that it sounds crazy, and I've been trying to fix it, but when I stream from netflix (HD content only) the ping times of my network will jump to about 600-900ms (from 40-ish ms) every 10 seconds.  Very goofy!   I've tried doing the same thing

  • How do I set my iPad to receive my email from aol and att

    How do I  set my iPad to receive my email from AT&T, and aol?

  • Change source (sql) of interactive report based on column value?

    I've got an Interactive report displaying 10 columns. What I'd like to do is show different columns depending on the value of the first column. All the rows in the result will have the same value in the first column. If value in column 1 (on any row)

  • Chart displays real quick

    I am using buffered data acquisition and i acquire at the rate of 20,000 samples per second and i write my data to a binary file. The problem is I view my data in a chart when recording the data. The chart is too fast, I want to reduce the speed of t

  • ISR adobe form unable to display the drop down

    Hi, I need to create a F4 help for a field in adobe form created using ISR. I have used the ISR text edit - Value help , But when i run the adobe form using the SFP tcode the F4 help is not displayed. Please suggest the way to populate the the input