Execution results (Merged instead of inserted and updated)

I am doing UPDATE/INSERT on the target table. But in the execution results it just gives the rows inserted or updated combined in the merged column.
Is there a way to get inserted and updated in appropriate columns.

I have not tried this recently - but I know the MERGE statement wasn't introduced until Oracle 9i. If you CONFIGURE the oracle module the map is in, and change the PL/SQL generation mode from "Default" to "Oracle 8i", I think it'll change the SQL to use INSERTS and UPDATES instead of the MERGE, which should give you what you want.
Warning though - this will change EVERY map in that module, and recompile using less efficient SQL. You might create a module just for the one map and set the generation mode for it, so that all the maps won't become less efficient.
Then again, the easier way is probably to simply have both an UPDATE_DATE and CREATE_DATE on your target table...if they are the same it was an INSERT, if different it was an UPDATE.
Hope this helps,
Scott

Similar Messages

  • Can we use both INSERT and UPDATE at the same time in JDBC Receiver

    Hi All,
    I would like to know is it possible to use both INSERT and UPDATE at the same time in one interface because I have a requirement in which I have to perform both the task.
    user send the file which contains both new and old record and I need to save those in MS SQL database.
    If the record exist then use UPDATE otherwise use INSERT.
    I looked on sdn but didn't find any blog which perform both the things at the same time.
    Interface Requirement
    FILE -
    > PI -
    > JDBC(INSERT & UPDATE)
    I am thinking to use JDBC Lookup but not sure if it good to use for bulk record.
    Can somebody please suggest me something or send me the link of any blog or anything to solve this problem.
    Thanks,

    Hi ,
              If I have understood properly the scenario properly,you are not performing insert and update together. As you posted
    "If the record exist then use UPDATE otherwise use INSERT."
    Thus you are performing either an insert or an update which depends on outcome of a search if the records already exist in database or not. Obviously to search the tables you need " select * from ...  where ...." query. If your query returns some results you proceed with update since this means there are some old records already in database. If your query returns no rows  you proceed with "insert into tablename....." since there are no old records present in database.
      Now perhaps the best method to do the searching, taking a decision to insert or update, and finally insert or update operation is to be done by a stored procedure in MS SQL database.  A stored procedure is a subroutine available to applications accessing a relational database system. Here the application is PI server.   If you need further help on how to write and call stored procedure in MS SQL you can look into these links
    http://www.daniweb.com/web-development/databases/ms-sql/threads/146829
    http://www.sqlteam.com/article/stored-procedures-parameters-inserts-and-updates
    [ This part you can ignore, Since its not sure that you will face this situation
        Still you might face some problems while your scenario runs. Lets consider this scenario, after the stored procedure searches the database it found no rows. Thus you proceed with an insert operation. If your database table is being accessed by multiple applications (or users) other than yours then it is very well possible that after the search operation completed with a null result, an insert/update operation has been performed by some other application with the same primary key. Now when you are trying to insert another row with same primary key you get an error message like "duplicate entry not possible for same primary key value". Thus you need to be careful in this respect. MS SQL has a feature called "exclusive locks ". Look into these links for more details on the subject
    http://msdn.microsoft.com/en-us/library/aa213039(v=sql.80).aspx
    http://www.mssqlcity.com/Articles/Adm/SQL70Locks.htm
    http://www.faqs.org/docs/ppbook/r27479.htm
    http://msdn.microsoft.com/en-US/library/ms187373.aspx
    http://msdn.microsoft.com/en-US/library/ms173763.aspx
    http://msdn.microsoft.com/en-us/library/e7z8d5hf(v=vs.80).aspx
    http://mssqlserver.wordpress.com/2006/11/08/locks-in-sql/
    http://www.mollerus.net/tom/blog/2008/03/using_mssqls_nolock_for_faster_queries.html
        There must be other methods to avoid this problem. But the point is you need to be sure that all access to database for insert/update operations are isolated.
    regards
    Anupam

  • Oracle forms 10g,multiple insert and update problem

    Hi,
    I have tabular form(4 records displayed) with one datablock(based on a view).
    After querying the form could not update all the records but only first record value can select from LOV.
    I called a procedure in in-insert and on-update
    The query is lik this
    PACKAGE BODY MAPPING IS
         PROCEDURE INSERT_ROW(EVENT_NAME IN VARCHAR2)
         IS
         BEGIN
              IF (EVENT_NAME = 'ON-INSERT') THEN
                   INSERT INTO XX_REC_MAPPING
                   (BRANCH_CODE,COLLECTION_ID,PAY_MODE_ID,RECEIPT_METHOD,CREATED_BY,
                   CREATION_DATE,LAST_UPDATED_BY,LAST_UPDATE_DATE,LAST_UPDATE_LOGIN)
                   VALUES
                   (     :XX_REC_MAPPING.OFFICE_CODE,
                        :XX_REC_MAPPING.COLLECTION_ID,
                        :XX_REC_MAPPING.PAY_MODE_ID,
                        :XX_REC_MAPPING.RECEIPT_METHOD,
                        :XX_REC_MAPPING.CREATED_BY,
                        :XX_REC_MAPPING.CREATION_DATE,
                        :XX_REC_MAPPING.LAST_UPDATED_BY,
                        :XX_REC_MAPPING.LAST_UPDATE_DATE,
                        :XX_REC_MAPPING.LAST_UPDATE_LOGIN);     
              ELSIF (EVENT_NAME = 'ON-UPDATE') THEN          
              UPDATE     XX_REC_MAPPING
              SET BRANCH_CODE=:XX_REC_MAPPING.OFFICE_CODE,
                        COLLECTION_ID=:XX_REC_MAPPING.COLLECTION_ID,
                        PAY_MODE_ID=:XX_REC_MAPPING.PAY_MODE_ID,
                        RECEIPT_METHOD=:XX_REC_MAPPING.RECEIPT_METHOD,
                        LAST_UPDATED_BY=:XX_REC_MAPPING.LAST_UPDATED_BY,
                        LAST_UPDATE_DATE=:XX_REC_MAPPING.LAST_UPDATE_DATE,
                        LAST_UPDATE_LOGIN=:XX_REC_MAPPING.LAST_UPDATE_LOGIN
                        WHERE ROWID=:XX_REC_MAPPING.ROW_ID;
              END IF;
         END INSERT_ROW;
    END MAPPING;
    Whether the table gets looked or sholud i use some other trigger or loops ?
    someone suggest me how to edit this query for multiple update.
    Thanks
    sat33

    I called a procedure in in-insert and on-updateWhy are you writing this code in the first place? If you have a block based on an updatable view, just let Forms do the inserts and updates.
    If it's not an updatable view, use instead of triggers on the view.
    See this current thread too:
    INSTEAD of Trigger View for an Oracle EBS New form development

  • Count of inserted and updated rowcount in @@rowcount

    Similarly I have created a sp which is inserting and updating the records.
    Now I want to track the count of new record inserted and updated record in @@rowcount .
    please suggest me the code .
    below is my sp
    alter Procedure SP_Archive_using_merge
    AS
    --exec SP_Archive
    BEGIN
    SET NOCOUNT ON
    Declare @Source_RowCount int
    Declare @New_RowCount int
    DECLARE @TimeIn SMALLDATETIME
    DECLARE @LatestVersion INT
    SET NOCOUNT ON
    ---BBxKey and Hash value of all the source columns are derived in source query itself--
    select @TimeIn=getdate(),@LatestVersion=1
    MERGE Archive.dbo.ArchiveBBxCemxr AS stm
    USING (
    SELECT a.*,cast(SUBSTRING(a.Col001,1,10) as varchar(100)) BBxKey,
    HashBytes('MD5', CAST(CHECKSUM(a.Col001,a.Col002,a.Col003,a.Col004,a.Col005,a.Col006,a.Col007) AS varbinary(max))) RowChecksum,
    b.BBxKey as Archive_BBxKey, b.RowChecksum as Archive_RowChecksum
    FROM dbo.ImportBBxCemxr a LEFT OUTER JOIN Archive.dbo.ArchiveBBxCemxr b
    ON a.Col001 = b.BBxKey
    Where (b.LatestVersion = 1 OR b.LatestVersion IS NULL) AND a.Col001 IS NOT NULL
    ) AS sd 
    ON sd.Archive_BBxKey = stm.BBxKey and sd.RowChecksum = stm.RowChecksum
    WHEN MATCHED AND (stm.BBxKey = sd.Archive_BBxKey and stm.RowChecksum != sd.Archive_RowChecksum) THEN
    UPDATE SET 
    stm.TimeIn = @TimeIn,
    BBXKey=sd.BBXKey,
    RowChecksum=sd.RowChecksum,
    stm.Col001=sd.Col001,
    stm.Col002=sd.Col002,
    stm.Col003=sd.Col003,
    stm.Col004=sd.Col004,
    stm.Col005=sd.Col005,
    stm.Col006=sd.Col006,
    stm.Col007=sd.Col007,
    stm.LatestVersion=@LatestVersion
    WHEN NOT MATCHED and (sd.Archive_BBxKey is null) THEN
    Insert (TimeIn,BBXKey,RowChecksum,Col001,Col002,Col003,Col004,Col005,Col006,Col007,LatestVersion)
    values(getdate(),sd.BBXKey,sd.RowChecksum,sd.Col001,sd.Col002,sd.Col003,sd.Col004,sd.Col005,sd.Col006,sd.Col007,@LatestVersion);
    end 
    Thankx & regards, Vipin jha MCP

    You need to OUTPUT clause with action column to get the info into teable variable and then count from the table variable.
    Try the below: (Not tested)
    alter Procedure SP_Archive_using_merge
    AS
    --exec SP_Archive
    BEGIN
    SET NOCOUNT ON
    Declare @Source_RowCount int
    Declare @New_RowCount int
    DECLARE @TimeIn SMALLDATETIME
    DECLARE @LatestVersion INT
    SET NOCOUNT ON
    ---BBxKey and Hash value of all the source columns are derived in source query itself--
    select @TimeIn=getdate(),@LatestVersion=1
    DECLARE @tableVariable TABLE (sAction VARCHAR(20), InsertedID INT, DeletedID INT)
    MERGE Archive.dbo.ArchiveBBxCemxr AS stm
    USING (
    SELECT a.*,cast(SUBSTRING(a.Col001,1,10) as varchar(100)) BBxKey,
    HashBytes('MD5', CAST(CHECKSUM(a.Col001,a.Col002,a.Col003,a.Col004,a.Col005,a.Col006,a.Col007) AS varbinary(max))) RowChecksum,
    b.BBxKey as Archive_BBxKey, b.RowChecksum as Archive_RowChecksum
    FROM dbo.ImportBBxCemxr a LEFT OUTER JOIN Archive.dbo.ArchiveBBxCemxr b
    ON a.Col001 = b.BBxKey
    Where (b.LatestVersion = 1 OR b.LatestVersion IS NULL) AND a.Col001 IS NOT NULL
    ) AS sd
    ON sd.Archive_BBxKey = stm.BBxKey and sd.RowChecksum = stm.RowChecksum
    WHEN MATCHED AND (stm.BBxKey = sd.Archive_BBxKey and stm.RowChecksum != sd.Archive_RowChecksum) THEN
    UPDATE SET
    stm.TimeIn = @TimeIn,
    BBXKey=sd.BBXKey,
    RowChecksum=sd.RowChecksum,
    stm.Col001=sd.Col001,
    stm.Col002=sd.Col002,
    stm.Col003=sd.Col003,
    stm.Col004=sd.Col004,
    stm.Col005=sd.Col005,
    stm.Col006=sd.Col006,
    stm.Col007=sd.Col007,
    stm.LatestVersion=@LatestVersion
    WHEN NOT MATCHED and (sd.Archive_BBxKey is null) THEN
    Insert (TimeIn,BBXKey,RowChecksum,Col001,Col002,Col003,Col004,Col005,Col006,Col007,LatestVersion)
    values(getdate(),sd.BBXKey,sd.RowChecksum,sd.Col001,sd.Col002,sd.Col003,sd.Col004,sd.Col005,sd.Col006,sd.Col007,@LatestVersion)
    OUTPUT $action as action, inserted.BBXKey as ins, deleted.BBXKey as del into @tableVariable;
    --To get the action count info
    SELECT sAction, COUNT(*) FROM @tableVariable GROUP BY sAction
    end

  • In jdbc adapter what is the difference between insert and update insert

    in jdbc adapter what is the difference between insert and update insert
    Edited by: katru vijay on Mar 22, 2010 7:43 AM

    Please refer to this Link [Document Formats for the Receiver JDBC Adapter|http://help.sap.com/saphelp_nw04/Helpdata/EN/22/b4d13b633f7748b4d34f3191529946/frameset.htm]
    Hope this helps.
    Regards,
    Chandravadan

  • Inserting and Updating records in ORACLE using WebDynpro Java

    Hi All
    I got connected to oracle backend (using my previous thread), but now i want to insert and update the records
    i have created views  for insert and update,
    Thanks in advance
    Sushma

    Hi shusma..
    chk this link..
    <b><u>Creating Connection</u></b>
    package com.sap.xirig;
    import javax.naming.*;
    import javax.sql.*;
    import java.sql.*;
    public class DBLookup {
    String Conn_Status = "Not Connected";
    String Language_Desc = "Empty";
    String Language_Cd = "Empty";
    Connection conn;
    Context ctx;
    DataSource ds;
    //Constructor for the DBLookup object
    public DBLookup {
    try {
    ctx = new InitialContext();
    if (ctx == null) {
    throw new Exception("Boom - No Context");
    // If JDBC 2.0 connection is used please create the DataSource object as below
    // ds = (DataSource) ctx.lookup("jdbc/ORACLEDATASOURCE");
    // If JDBC 1.0 connection is used please create the DataSource object as below
    // ds = (DataSource) ctx.lookup("jdbc/notx/ORACLEDATASOURCE");
    if (ds == null) {
    throw new Exception("Boom - No dataSource");
    catch (Exception e) {
    e.printStackTrace();
    public String getLanguageDesc(String v_str) {
    Statement stmt = null;
    ResultSet rst = null;
    try {
    if (ds != null) {
    conn = ds.getConnection();
    Conn_Status = "Could not get connection to
    datasource";
    if (conn != null) {
    Conn_Status = "Got Connection " +
    conn.toString();
    stmt = conn.createStatement();
    rst = stmt.executeQuery("SELECT
    LANGUAGE_DESC FROM LANGUAGETRANSLATION WHERE LANGUAGE_CD='" + v_str +
    if (rst.next()) {
    Language_Desc = rst.getString(1);
    conn.close();
    catch (Exception e) {
    e.printStackTrace();
    finally {
    if (rst != null) {
    try {
    rst.close();
    catch (Exception e) {
    e.printStackTrace();
    if (stmt != null) {
    try {
    stmt.close();
    catch (Exception e) {
    e.printStackTrace();
    if (conn != null) {
    try {
    conn.close();
    catch (Exception e) {
    e.printStackTrace();
    return Language_Desc;
    http://e-docs.bea.com/wls/docs81/oracle/API_joci.html
    Hope this will help u..
    URs GS

  • Find All INSERTs and UPDATEs

    Hi All;
    I want to find out all inserts and updates of a spesific table. For instance a package l,ke that
    CREATE OR REPLACE PACKAGE BODY param_test IS
      PROCEDURE ins_test IS
      BEGIN
    insert INTO parameter_value VALUES (2);
        INSERT INTO parameter_value VALUES (9);
        INSERT  INTO
        parameter_value VALUES (4);   
        insert INTO parameter_value VALUES (54);
      END ins_test;
    END param_test;I am querying user_source view. My query is below.
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
    Connected as SYS
    SQL> SELECT us1.NAME, us1.line, us1.text
      2    FROM user_source us1,
      3         (SELECT us2.line, us2.NAME, us2.text
      4            FROM user_source us2
      5           WHERE regexp_like(upper(us2.text), '[[:space:]]*PARAMETER_VALUE[[:space:]]*')) us3
      6   WHERE us3.line - 1 = us1.line
      7     AND us1.NAME = us3.NAME
      8     AND regexp_like(upper(us1.text), '[[:space:]]*(INSERT[[:space:]]*INTO|UPDATE)[[:space:]]*')
      9  /
    NAME                                 LINE TEXT
    PARAM_TEST                              9 insert INTO parameter_value VALUES (2);
    PARAM_TEST                             12     INSERT  INTO
    SQL> My question is "Are tehre any solutions to overcome this situation?"
    Kindly Regards...

    You might be better off combining into your attack the use of user_dependencies. This will tell you what objects e.g., code is dependent on your table and then you can search the source of those modules for inserts and updates into the table. Even then you'll never be sure, especially if dynamic SQL is used as the statement may be pieced together from various bits if strings, as then user_dependencies won't contain the reference.

  • Connecting to datasource and retrieve, insert and update data in SQL Server

    hi,
    i am trying to retrieve, insert and update data from SQL Server 2000 and display in JSPDynPage and is for Portal Application. I have already created datasource in visual composer. Is there any sample codes for mi to use it as reference???
    Thanks
    Regards,
    shixuan

    Hi,
    See this link
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6209b52e-0401-0010-6a9f-d40ec3a09424
    Regards,
    Senthil kumar K.

  • Connecting to datasource and retrieve, insert and update data

    hi,
    i am doing a JSP page that need to retrieve data and display on textView, insert data and update data. I have already create a datasource in Visual Composer. Does anyone have a sample codes for mi to use it as reference. So that i can connect to the datasource tat i created in Visual composer and retrieve, insert and update data. thanz
    Regards,
    shixuan

    Hi,
    After creating a data source in Visual composer .
    you have to create a BI system that Visual Composer can use in
    the SAP NetWeaver Portal.
    refer this pdf file for further Info
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6209b52e-0401-0010-6a9f-d40ec3a09424
    Regards,
    Beevin

  • "reproc: Insert and Update failed on" replicated table

    Hello, I've published a new publication item on an Oracle Lite Server (9i and mobile server 5.0.2.10).
    After inserting records on the server replicated table (Table1), when I try to sync some devices, I have the following error message on the client PDA "reproc Insert and Update failed on " Table1.
    If I empty the server table's records, then the client PDA syncs OK.
    Can someone refresh me with the cause of this error ?
    Thank's in advance.
    Regards,
    Olivier

    Hi,
    This is my actual requirement.
    During the updates i.e update process and delete process, if the filed status is changed to 'O', '0' or ' ' in SAP, then those records in Oracle should be deleted.
    if the field status is changed to other than 'O', '0', or ' ' SAP, then those records needs to be updated with the remaining information
    How do XI Know that these fields are changed in the SAP table to perform delete ,is some notification required when there is change in SAP Table through proxy ?

  • Multiple rows insert and update form example

    I just want to share with you an example of a multiple rows insert and update form. You can access it HERE (http://tryapexnow.com/apex/f?p=12090:21)
    You will find on the same page the complete description of all elements used to buid it.
    I'm waiting for opinions, suggestions, and questions here in this thread.
    Thanks

    Hello Valentin,
    I got an error message when I clicked on the weblink. Here is the message
    Error ERR-7620 Could not determine workspace for application. Could you please take a look at this.
    Thanks,
    Karol

  • Not Properly Insert and Update in ODI interfaces

    Dear Brothers,
    The records are not inserting and updating even the CDC captured in the journal in one of my package. But, stopped and execute again then there is inserts and updates. I am not able to understand where the problem is. Can u suggest regarding the issue.

    Dear Bro,
    I am capturing CDC using consistent set. I am using (LKM SQL to DB2 UDB). While executing the package, the records are locked and extend window, but there is no inserts and updates into the database. It is throwing error as row index out of range while running the query. The query is running in Source Stage for ex. RTO_STAGE.JV$NUMGEN. query is triggering but records are not properly inserted and updated in the target.
    First time i saw in the CDC table, there was some 10 records available while executing no insert and update. Then, i stopped it and execute it again at that time i checked in the CDC table ie., the same table, but there was only 2 records available in CDC the old records were disappeared.
    I dont know the exact issue? My colleague is telling may be SNP tables not refreshing. Kindly suggest any solution.

  • Errors when inserting and updating form using VIEW.

    Here's my view:
    CREATE OR REPLACE FORCE
    VIEW  "SH_ADD_EMPLOYEES_VW" ("EMP_ID", "DEPT_ID", "JOB_DESC_ID", "EMPNO", "EMP_FIRST", "EMP_LAST", "USER_NAME", "USER_INI", "DEPTNO", "DEPT_DESC", "ROLES_ID", "ADMIN", "CREATES", "APPROVES", "QUALITY", "CUST_SVC", "SH_LOCAL",
    "SH_OFFICE", "SYSTEM")
    AS
      select
    "SH_EMPLOYEES"."EMP_ID" as "EMP_ID",
    "SH_EMPLOYEES"."DEPT_ID" as "DEPT_ID",
    "SH_EMPLOYEES"."JOB_DESC_ID" as "JOB_DESC_ID",
    "SH_EMPLOYEES"."EMPNO"  as "EMPNO",
    "SH_EMPLOYEES"."EMP_FIRST" as "EMP_FIRST",
    "SH_EMPLOYEES"."EMP_LAST" as "EMP_LAST",
    "SH_EMPLOYEES"."USER_NAME" as "USER_NAME",
    "SH_EMPLOYEES"."USER_INI" as "USER_INI",
    "SH_EMPLOYEES"."DEPTNO" as "DEPTNO",
    "SH_EMPLOYEES"."DEPT_DESC" as "DEPT_DESC",
    "DOC_ROLES"."ROLES_ID" as "ROLES_ID",
    "DOC_ROLES"."ADMIN" as "ADMIN",
    "DOC_ROLES"."CREATES" as "CREATES",
    "DOC_ROLES"."APPROVES" as "APPROVES",
    "DOC_ROLES"."QUALITY" as "QUALITY",
    "DOC_ROLES"."CUST_SVC" as "CUST_SVC",
    "DOC_ROLES"."SH_LOCAL" as "SH_LOCAL",
    "DOC_ROLES"."SH_OFFICE" as "SH_OFFICE",
    "DOC_ROLES"."SYSTEM" as "SYSTEM"
    FROM "SH_EMPLOYEES" "SH_EMPLOYEES", "DOC_ROLES" "DOC_ROLES"
    where "SH_EMPLOYEES"."EMP_ID" = "DOC_ROLES"."EMP_ID"
    Here's my trigger (note - I am not using the EXCEPTION clause or (declaration of it)  because it throws an error on msg=>: 'This is my message.' Any help here would be great as well.)
    CREATE OR REPLACE TRIGGER bi_ADD_EMPLOYEES_VW
    INSTEAD OF insert ON SH_ADD_EMPLOYEES_vw
    for each row
    declare
    duplicate_info EXCEPTION;
    PRAGMA EXCEPTION_INIT(duplicate_info, -00001);
    begin
    insert into SH_EMPLOYEES
    (EMP_ID, DEPT_ID, JOB_DESC_ID, EMPNO, EMP_FIRST, EMP_LAST, USER_NAME, USER_INI, DEPTNO, DEPT_DESC)
    values
    (:new.EMP_ID, :new.DEPT_ID, :new.JOB_DESC_ID, :new.EMPNO, :new.EMP_FIRST, :new.EMP_LAST, :new.USER_NAME, :new.USER_INI, :new.DEPTNO, :new.DEPT_DESC);
    insert into DOC_ROLES
    (ROLES_ID, ADMIN, CREATES, APPROVES, QUALITY, CUST_SVC, SH_LOCAL, SH_OFFICE, SYSTEM)
    VALUES (
    :new.ROLES_ID, :new.ADMIN, :new.CREATES, :new.APPROVES, :new.QUALITY, :new.CUST_SVC, :new.SH_LOCAL, :new.SH_OFFICE, :new.SYSTEM);
    EXCEPTION
    WHEN duplicate_info THEN
      RAISE_APPLICATION_ERROR (
       num=> -20107
       msg=> 'Duplicate employee');
    END bi_ADD_EMPLOYEES_VW;
    ERROR ON UPDATE:
    ORA-20505: Error in DML: p_rowid=1001,
    p_alt_rowid=EMP_ID, p_rowid2=2, p_alt_rowid2=ROLES_ID. ORA-01779: cannot modify
    a column which maps to a non key-preserved table
    ERROR ON INSERT:
    ORA-01400: cannot insert NULL into
    ("SPICE_HUNTER1"."SH_EMPLOYEES"."EMP_ID") ORA-06512: at
    "SPICE_HUNTER1.BI_SH_ADD_EMPLOYEES_VW", line 3 ORA-04088: error during execution
    of trigger 'SPICE_HUNTER1.BI_SH_ADD_EMPLOYEES_VW' ORA-06512: at
    "SYS.WWV_DBMS_SQL", line 549 ORA-06512: at "APEX_040000.WWV_FLOW_DML", line 1121
    ORA-22816: unsupported feature with RETURNING clause
    Error Unable to process row on table SH_ADD_EMPLOYEES_VW

    From what I see you are not handling emp_id when it is null.. you need to assign it a value when null from sequence.. that column cannot be null, hence the error, and in order to "modify" a column in that table the DML needs that id to have a value.

  • Insert and update query to calculate the opening and closing balance

    create table purchase(productid number(5) ,dateofpurchase date,
    qty number(5));
    create table inventory(invid number(5),productid number(5),
    idate date,openingqty number(5),closingqty number(5));
    Records in inventory:
    1,1,'01-jan-2009', 10, 20
    2,1,'03-jan-2009', 20, 30
    3,1,'04-jan-2009', 40, 50
    when I enter the purchase invoice for 15 qty on 02-jan-2009
    after say '15-jan-09' , a new record should get inserted
    with opening balance = (closing balance before 02-jan-2009)
    and all the opening and closing balance for that product should
    get affected.
    If the invoice for 20 qty is entered for the existing date say
    '03-jan-2009' in inventory , then the closing balance
    for 03-jan-2009 should get updated and all the following records
    should get affected.
    I need the insert for the first one and update query for the
    second one.
    Vinodh

    <strike>You can do this in one statement by using the merge statement</strike>
    Hmm, maybe I spoke too soon.
    Edited by: Boneist on 25-Sep-2009 13:56
    Thinking about it, why do you want to design your system like this?
    Why not simply have your purchases table hold the required information and then either work out the inventory on the fly, or have a job that calls a procedure to add a row for the previous day?
    If you continue with this design, you're opening yourself up to a world of pain - what happens when the data doesn't match the purchases table? Also when is the inventory cut-off to reset the opening/closing balances? Monthly? Annually? Weekly? If it's set to one of those, what happens when the business request the inventory for a particular week?
    Edited by: Boneist on 25-Sep-2009 13:59

  • Inserting and updating only if there is no locks

    Is there a way to insert or update or merge data in table only if there is no locks i.e. if another process is executing update into table with a key = 1 and I'm trying to perform update for the same row then nothing happens and if no one is locking row then update is performed.
    In sql server I can do it this way:
    update my_table with (NOWAIT) set row1 = 1 where key = 1;
    Is there a way to do something similar in oracle?

    LeopoldStoch wrote:
    Is there a way to insert or update or merge data in table only if there is no locks i.e. if another process is executing update into table with a key = 1 and I'm trying to perform update for the same row then nothing happens and if no one is locking row then update is performed.
    In sql server I can do it this way:
    update my_table with (NOWAIT) set row1 = 1 where key = 1;
    Is there a way to do something similar in oracle?I think you'd want to do some reading about optimistic and pessimistic locking. Assuming this is any kind of web app (stateless environment), you'd likely want to drop some optimistic locking routine in place to ensure that the row you are trying to update hasn't been changed since your last view of the data.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:5771117722373
    When you have 2 sessions attempting to update the same data, Oracle locks the record for you. Session #2's update cannot be applied until session #1 has either committed or rolled back it's transaction against the row being modified. However session 2 will wait until session 1 commits or rolls back ... so you wouldn't "know" the row was being touched unless you did some programming to determine this.
    You also may want to understand how Oracle implements things (it's quite different than the default SQL Server implementation).
    http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/consist.htm#CNCPT221

Maybe you are looking for

  • Need Help In Displaying Numberic Values In app.alert

    How can I display a two placed decimal value in an app.alert, correctly? app.alert("Invalid  - " + this.getField("Sub-Total-2").value, 1); In the above alert, Sub-Total-2 is defined with 2 decimal places, within its Text Field Properties. But if its

  • DVI-D switch?

    I have both a Mac Pro and a PC, both with DVI-D output. I'd like to drive a single display with either box, without having to manually move the display cable from one box's video output connector to the other. The ideal solution would be to plug the

  • Web Gallery and iWeb

    There is a template in iWeb for albums, but not one for iPhoto Web Galleries. You can use the insert .mac web gallery option to get a web gallery onto a page, but is there a way to use the cool album template instead? It seems so odd that there isn't

  • Smartform - Font Issue

    Hi Experts, I am having font issue in smartform. I have created style as zz_style, using Helve, 9. In smartform z_smartform, I set in output options tab in Form Attribute to use style zz_style. But somehow the output comes out with different font for

  • Has any one upgrade ZOOM forms to R12?

    Dear All, Currently we are upgrading from 11.5.10.2 to R12.1.3, As per R12 there are some forms are moved to OAF Pages, we have zoom functions created in 11i for those forms, Any idea on this ? Regards, Nagu