Checkboxes in report to insert or update a value, doesn't do both

I'm going crazy trying to solve this, hopefully someone can help me out. At the moment, I have a credit card table that will contain the information relating to a user-credit card pairing. Banks and such can submit credit cards to users, and the credit card table will be updated, with the column Approved_Flag being set to "N". Now, in another page, I have a report that displays any credit cards that a user may want, along with checkboxes. This report contains any bank submitted cards, or any cards that have been marked "General". Users can decide which ones they would like to keep, and then hit a submit button, which will update the credit card table. Existing records in the table would have the Approved column marked 'Y', new records from the so called "General" cards would be inserted.
The issue is that with the code I've written, it updates any existing records in the credit card table perfectly, but it will not insert any new information. The following is my code for the process that activates when the submit button is hit:
FOR i in 1..APEX_APPLICATION.G_F01.count
LOOP
MERGE INTO ls_credit_cards dest
USING( SELECT apex_application.g_f01(i) credit_card_id,
:F125_USER_ID created_by,
sysdate created_on,
:P54_CARDS card_id,
:P54_USER user_id,
'Y' approved_flag
FROM dual) src
ON( dest.credit_card_id = src.credit_card_id )
WHEN MATCHED
THEN
UPDATE SET dest.approved_flag = src.approved_flag
WHEN NOT MATCHED
THEN
INSERT( credit_card_id,
created_by,
created_on,
card_id,
user_id,
approved_flag )
VALUES( src.credit_card_id,
src.created_by,
src.created_on,
src.card_id,
src.user_id,
src.approved_flag );
END LOOP;
Through some testing, I've found out the the issue is any "General" credit cards will not have a credit card ID assigned to them. By hard coding it, I can get them to insert, but then existing records do not get updated. I've used this code to assign each checkbox in the table a credit_card_id (I think...) so I don't understand why this isn't working.
APEX_ITEM.CHECKBOX(1,credit_card_id) " ",
Could anyone shed some light on how I can do this? I would appreciate it IMMENSELY

A Trigger is just a set of code that runs when certain DML events are applied to a specific table. Here's an example of a simple trigger that assigns a value to a key field when no value is supplied (NULL). Notice that the trigger makes use of another structure - a Sequence - for determining the ID. Sequences are just auto-incrementing values that are very useful for deriving unique values for use in primary key fields, etc.
Here's an example of how to create a sequence using SQL:
CREATE SEQUENCE SEQ_MVR_RATING_SCALE
    MINVALUE 1 INCREMENT BY 1 START WITH 1
/You can also create them directly using the SQL Workshop portion of the APEX console.
Here's an example of how to create a trigger that uses that sequence to populate the key value:
CREATE OR REPLACE TRIGGER  BI_MVR_RATING_SCALE
  before insert on MVR_RATING_SCALE
  for each row
declare
begin
  if :NEW.MVR_RATING is null then
    select SEQ_MVR_RATING_SCALE.nextval into :NEW.MVR_RATING from dual;
  end if;
  if :NEW.ENTERED_BY is null then
    :NEW.ENTERED_BY := FN_GET_USER(nvl(v('APP_USER'),user));
  end if;
  :NEW.ENTERED_ON := SYSDATE;
end;
/Without giving you a complete tutorial on triggers, just note the call to SEQ.nextval. That's what retrieves the next value from the sequence and tells the DB engine to increment the sequence value. The next time it is called, it will then be a different value.

Similar Messages

  • How to insert or update multiple values into a records of diff fields

    Hai All
    I have to insert or update or multiple values into a single records of diff fields from one to another table.
    Table1 has 3 fields
    Barcode bardate bartime
    0011 01-02-10 0815
    0022 01-02-10 0820
    0011 01-02-10 1130
    0022 01-02-10 1145
    0011 01-02-10 1230
    0022 01-02-10 1235
    0011 01-02-10 1645
    0022 01-02-10 1650
    these are the times that comes in at 0815 and goes break at 1130 and comes in at 1230 and goes home at 1645
    from these table i have to insert into another table called table2
    and the fields are barcode, date,timein intrin,introut,tiomout
    And the output want to like this
    barcode timein intrin introut timeout date
    0011 0815 1130 1230 1645 01-02-10
    0022 0820 1145 1235 1650 01-02-10
    If any give some good answer it will be help full..
    Thanks & Regards
    Srikkanth.M

    SQL> with table1 as (
      2  select '0011' Barcode,'01-02-10' bardate,'0815' bartime from dual union
      3  select '0022','01-02-10','0820' from dual union
      4  select '0011','01-02-10','1130' from dual union
      5  select '0022','01-02-10','1145' from dual union
      6  select '0011','01-02-10','1230' from dual union
      7  select '0022','01-02-10','1235' from dual union
      8  select '0011','01-02-10','1645' from dual union
      9  select '0022','01-02-10','1650' from dual
    10  )
    11  select barcode, bardate,
    12         max(decode(rn,1,bartime,null)) timein,
    13         max(decode(rn,2,bartime,null)) intrin,
    14         max(decode(rn,3,bartime,null)) introut,
    15         max(decode(rn,4,bartime,null)) timeout from (
    16                          select barcode, bardate, bartime,
    17                                 row_number() over (partition by barcode, bardate
    18                                                    order by bartime) rn
    19                            from table1)
    20  group by barcode, bardate;
    BARC BARDATE  TIME INTR INTR TIME
    0011 01-02-10 0815 1130 1230 1645
    0022 01-02-10 0820 1145 1235 1650Max
    http://oracleitalia.wordpress.com

  • How to insert or update comparing values  with two or more table

    Hai All
    I have three or four table in my database.
    Table 1 Dailattend is the main table here i need to insert or update my data and the fieds are
    Emplcode number,attdate date, intime date,intrin date ,introut date, outtime date are the fields
    Table 2 acclempbarcode the fields are
    emplcode number ,barcode number ....etc
    so now my data is in text format and i have broke the date like this
    0011221100112200100320100815
    First 16 is barcode and next 8 is date and 4 is time and i have created a temp table and store the date and move to main table
    My problem is the main table dailattend has no barcode so when i am going to insert or update i need to check whether the barcode is match with the emplcode in the main table
    How can i write insert or update statement
    The data is like this
    00110022 is barcode,10-03-2010 is my date and 0815 is time so i need to insert into dailattend table so now i have emplcode in dailattend table so i need to compare the barcode belong the emplcode in the another table and i need to insert in the dailattend table
    Pls give me some solution with example
    Regards
    Srikkanth.M

    try somthing like this
    create table t1
    as
    select '0011221100112200' barcode,to_date('100320100815','ddmmyyyyhh24mi') dt
    from dual
      create table barcodetbl
      emplcode varchar2(2000)
      barcode varchar2(2000)
      datetime date
    merge into barcodetbl bc
    using( select  * from  t1) x
    on
    (bc.barcode = x.barcode)
    when matched
    then update
    set datetime = x.dt
    when not matched
    then
    insert (emplcode,barcode,datetime)
    values(1,x.barcode,x.dt)
    /didn't realize that barcode is not in the main table.
    something along the lines
    Table 1 Dailattend is the main table here i need to insert or update my data and the fieds are
    Emplcode number,attdate date, intime date,intrin date ,introut date, outtime date are the fields
    Table 2 acclempbarcode the fields are
    emplcode number ,barcode number ....etc
    merge into dailattend bc
    using( select  * from  t1, acclempbarcode ac where t1.barcode = ac.barcode) x
    on
    (bc.emplcode = x.emplcode)
    when matched
    then update
    set datetime = x.dt
    when not matched
    then
    insert (emplcode,datetime)
    values(1,x.dt)
    /Alvinder
    Edited by: alvinder on Mar 23, 2010 3:50 PM

  • Insert OR Update records

    Hi All,
    I want to write a stored procedure to insert or update the value into the customer table. If the record exist, I need to insert. If it does not exist, I need to update. Could you tell me how do we do it.
    My Current stored procedure is :
    CREATE OR REPLACE PROCEDURE customer_update
    (p_cust_id IN VARCHAR2,
    p_cust_name IN VARCHAR2)
    AS
    BEGIN
    INSERT INTO CUSTOMER (cust_id, cust_NAME, update_dm)
    VALUES (p_cust_id, p_cust_name, sysdate);
    COMMIT;
    END customer_update;

    I think we need to be careful about using EXCEPTION to handle normal (expected) processing. Also, if the row is more likely to exist than not exist, it might be better to try the UPDATE first, and only go for INSERT if SQL%ROWCOUNT = 0;
    There's been a few of these sort of questions posted recently, and I find them worrying, becuase it suggests poorly designed systems. The user ought to know whether they are inserting a new record or amending an existing one. The MERGE functionality is useful for data migration/upload scenarios, but I think using it in a business situation is, in the words of Kent Beck, a "code smell".
    Cheers, APC

  • Report to Form (in Update mode), update, "Close" back to report (just like QBE).

    Alright, I have been through the entire board and found bit and pieces here and there on how to do this, but I am not satisfied with the results. Answers to these questions will dictate whether we use this product or not.
    1) The QBE solution is great for the above EXCEPT I am unable (it seems) to make updates to the form portion of the Report/Form combination. I need to be able to lock off certain fields and disallow certain functions. Other's have asked whether this can be done. No answers issued forth.
    Is there some way short of hacking into the PL/SQL code of updating the form on a wizard created QBE?
    2) I was able to create my own report, link (via link object) to a custom form (update the form as I needed). Now I would like my users not to have to hit the query button (which is absurd in this case because they already have the proper record displayed). So I need to open the form in "update" mode. I have seen some different approaches to this on the board, and all kinds of code, but is there a simple way to do this (preferably from the tool, not hacking code)?
    I see the code in the various posting (including the FAQ), the question is where I put in in the context of my link from report to form (if it is in the native pl/sql, this is not an answer because we will not go that route; having code blown away by the tool and have to be reentered. It goes in in the context of the tool or we don't use the tool).
    Also, is there a way to utilize the "close" button from the QBE that so nicely takes you back to the report and does a refresh?
    This is the simplest app I could dream up to test this product and it looks like it falls short.
    In summation:
    1) Generate a report. (yes)
    2) Link to form (yes)
    2a) Link direct to record (no query click) (no, without hacking)
    3) update the form (yes, if after query click)
    4) Jump back to report at spot where you left, do automatic refresh (just like QBE) (No, without hacking)
    Again, this is the simplest and most common of apps, I cannot understand why it would be so hard to accomplish. What am I missing? Anybody on the board, please advise.
    null

    If your report is created using ‘Reports From SQL Query’ then you can modify it using the following to achieve this:
    1. Remove the link from ‘Column Formatting’ section of the report object.
    2. In the SQL of the report , use custom link to the column where you want to provide link using the syntax
    select a.empno,’‘||a.ename||’‘ ename_link,a.deptno
    from scott.emp a
    Order by a.empno
    and the form will always open in ‘INSERT’ mode with passed values filled in.
    Thanks
    Krishnamurthy

  • Insert or Update data in SAP with Business Objects?

    Hi all,
    I am new to Business Objects world with my little expertise in Crystal Reports and Xclesius.
    Could you please clarify me that is there any solution or technology or Product of Business Objects which not only make impressive dashboards and analyze the data but also can communicate with back end SAP R/3 to save or update data.
    We are actually analyzing our Client requirements in which there is a need of Dashboards as well as some custom configurations that needs to be saved somewhere in the SAP system in order to make decisions in future.
    Our back end system is SAP BW. One possibility is to use Adobe Flex as a base architecture with BSP and BW but we are more concerned with what BOBJ provides.
    Looking forward for your suggestions.
    Kind Regards
    Umer Farooq

    GR81 wrote:
    I would like to know how I can insert or update data in a Google Spreadsheet from an Oracle Database please?
    Thanks,you can't since Oracle knows nothing about spreadsheets; Google or otherwise.

  • ORA-01456 : may not perform insert/delete/update operation

    When I use following stored procedure with crystal reports, following error occurs.
    ORA-01456 : may not perform insert/delete/update operation inside a READ ONLY transaction
    Kindly help me on this, please.
    My stored procedure is as under:-
    create or replace
    PROCEDURE PROC_FIFO
    (CV IN OUT TB_DATA.CV_TYPE,FDATE1 DATE, FDATE2 DATE,
    MSHOLD_CODE IN NUMBER,SHARE_ACCNO IN VARCHAR)
    IS
    --DECLARE VARIABLES
    V_QTY NUMBER(10):=0;
    V_RATE NUMBER(10,2):=0;
    V_AMOUNT NUMBER(12,2):=0;
    V_DATE DATE:=NULL;
    --DECLARE CURSORS
    CURSOR P1 IS
    SELECT *
    FROM FIFO
    WHERE SHARE_TYPE IN ('P','B','R')
    ORDER BY VOUCHER_DATE,
    CASE WHEN SHARE_TYPE='P' THEN 1
    ELSE
    CASE WHEN SHARE_TYPE='R' THEN 2
    ELSE
    CASE WHEN SHARE_TYPE='B' THEN 3
    END
    END
    END,
    TRANS_NO;
    RECP P1%ROWTYPE;
    CURSOR S1 IS
    SELECT * FROM FIFO
    WHERE SHARE_TYPE='S'
    AND TRANS_COST IS NULL
    ORDER BY VOUCHER_DATE,TRANS_NO;
    RECS S1%ROWTYPE;
    --BEGIN QUERIES
    BEGIN
    DELETE FROM FIFO;
    --OPENING BALANCES
    INSERT INTO FIFO
    VOUCHER_NO,VOUCHER_TYPE,VOUCHER_DATE,TRANS_QTY,TRANS_AMT,TRANS_RATE,
    SHOLD_CODE,SHARE_TYPE,ACC_NO,SHARE_CODE,TRANS_NO)
    SELECT TO_CHAR(FDATE1,'YYYYMM')||'001' VOUCHER_NO,'OP' VOUCHER_TYPE,
    FDATE1-1 VOUCHER_DATE,
    SUM(
    CASE WHEN
    --((SHARE_TYPE ='S' AND DTAG='Y')
    SHARE_TYPE IN ('P','B','R','S') THEN
    TRANS_QTY
    ELSE
    0
    END
    ) TRANS_QTY,
    SUM(TRANS_AMT),
    NVL(CASE WHEN SUM(TRANS_AMT)<>0
    AND
    SUM
    CASE WHEN SHARE_TYPE IN ('P','B','R','S') THEN
    TRANS_QTY
    ELSE
    0
    END
    )<>0 THEN
    SUM(TRANS_AMT)/
    SUM
    CASE WHEN SHARE_TYPE IN ('P','B','R','S') THEN
    TRANS_QTY
    ELSE
    0
    END
    ) END,0) TRANS_RATE,
    MSHOLD_CODE SHOLD_CODE,'P' SHARE_TYPE,SHARE_ACCNO ACC_NO,
    SHARE_CODE,0 TRANS_NO
    FROM TRANS
    WHERE ACC_NO=SHARE_ACCNO
    AND SHOLD_CODE= MSHOLD_CODE
    AND VOUCHER_DATE<FDATE1
    --AND
    --(SHARE_TYPE='S' AND DTAG='Y')
    --OR SHARE_TYPE IN ('P','R','B'))
    group by TO_CHAR(FDATE1,'YYYYMM')||'001', MSHOLD_CODE,SHARE_ACCNO, SHARE_CODE;
    COMMIT;
    --TRANSACTIONS BETWEEND DATES
    INSERT INTO FIFO
    TRANS_NO,VOUCHER_NO,VOUCHER_TYPE,
    VOUCHER_DATE,TRANS_QTY,
    TRANS_RATE,TRANS_AMT,SHOLD_CODE,SHARE_CODE,ACC_NO,
    DTAG,TRANS_COST,SHARE_TYPE
    SELECT TRANS_NO,VOUCHER_NO,VOUCHER_TYPE,
    VOUCHER_DATE,TRANS_QTY,
    CASE WHEN SHARE_TYPE='S' THEN
    NVL(TRANS_RATE-COMM_PER_SHARE,0)
    ELSE
    NVL(TRANS_RATE+COMM_PER_SHARE,0)
    END
    ,TRANS_AMT,SHOLD_CODE,SHARE_CODE,ACC_NO,
    DTAG,NULL TRANS_COST,SHARE_TYPE
    FROM TRANS
    WHERE ACC_NO=SHARE_ACCNO
    AND SHOLD_CODE= MSHOLD_CODE
    AND VOUCHER_DATE BETWEEN FDATE1 AND FDATE2
    AND
    ((SHARE_TYPE='S' AND DTAG='Y')
    OR SHARE_TYPE IN ('P','R','B'));
    COMMIT;
    --PURCHASE CURSOR
    IF P1%ISOPEN THEN
    CLOSE P1;
    END IF;
    OPEN P1;
    LOOP
    FETCH P1 INTO RECP;
    V_QTY:=RECP.TRANS_QTY;
    V_RATE:=RECP.TRANS_RATE;
    V_DATE:=RECP.VOUCHER_DATE;
    dbms_output.put_line('V_RATE OPENING:'||V_RATE);
    dbms_output.put_line('OP.QTY2:'||V_QTY);
    EXIT WHEN P1%NOTFOUND;
    --SALES CURSOR
    IF S1%ISOPEN THEN
    CLOSE S1;
    END IF;
    OPEN S1;
    LOOP
    FETCH S1 INTO RECS;
    EXIT WHEN S1%NOTFOUND;
    dbms_output.put_line('OP.QTY:'||V_QTY);
    dbms_output.put_line('SOLD:'||RECS.TRANS_QTY);
    dbms_output.put_line('TRANS_NO:'||RECS.TRANS_NO);
    dbms_output.put_line('TRANS_NO:'||RECS.TRANS_NO);
    IF ABS(RECS.TRANS_QTY)<=V_QTY
    AND V_QTY<>0
    AND RECS.TRANS_COST IS NULL THEN
    --IF RECS.TRANS_COST IS NULL THEN
    --dbms_output.put_line('SOLD:'||RECS.TRANS_QTY);
    --dbms_output.put_line('BAL1:'||V_QTY);
    UPDATE FIFO
    SET TRANS_COST=V_RATE,
    PUR_DATE=V_DATE
    WHERE TRANS_NO=RECS.TRANS_NO
    AND TRANS_COST IS NULL;
    COMMIT;
    dbms_output.put_line('UPDATE TRANS_NO:'||RECS.TRANS_NO);
    dbms_output.put_line('OP.QTY:'||V_QTY);
    dbms_output.put_line('SOLD:'||RECS.TRANS_QTY);
    dbms_output.put_line('TRANS_NO:'||RECS.TRANS_NO);
    dbms_output.put_line('BAL2:'||TO_CHAR(RECS.TRANS_QTY+V_QTY));
    END IF;
    IF ABS(RECS.TRANS_QTY)>ABS(V_QTY)
    AND V_QTY<>0 AND RECS.TRANS_COST IS NULL THEN
    UPDATE FIFO
    SET
    TRANS_QTY=-V_QTY,
    TRANS_COST=V_RATE,
    TRANS_AMT=ROUND(V_QTY*V_RATE,2),
    PUR_DATE=V_DATE
    WHERE TRANS_NO=RECS.TRANS_NO;
    --AND TRANS_COST IS NULL;
    COMMIT;
    dbms_output.put_line('UPDATING 100000:'||TO_CHAR(V_QTY));
    dbms_output.put_line('UPDATING 100000 TRANS_NO:'||TO_CHAR(RECS.TRANS_NO));
    INSERT INTO FIFO
    TRANS_NO,VOUCHER_NO,VOUCHER_TYPE,
    VOUCHER_DATE,TRANS_QTY,
    TRANS_RATE,TRANS_AMT,SHOLD_CODE,SHARE_CODE,ACC_NO,
    DTAG,TRANS_COST,SHARE_TYPE,PUR_DATE
    VALUES
    MCL.NEXTVAL,RECS.VOUCHER_NO,RECS.VOUCHER_TYPE,
    RECS.VOUCHER_DATE,RECS.TRANS_QTY+V_QTY,
    RECS.TRANS_RATE,(RECS.TRANS_QTY+V_QTY)*RECS.TRANS_RATE,RECS.SHOLD_CODE,
    RECS.SHARE_CODE,RECS.ACC_NO,
    RECS.DTAG,NULL,'S',V_DATE
    dbms_output.put_line('INSERTED RECS.QTY:'||TO_CHAR(RECS.TRANS_QTY));
    dbms_output.put_line('INSERTED QTY:'||TO_CHAR(RECS.TRANS_QTY+V_QTY));
    dbms_output.put_line('INSERTED V_QTY:'||TO_CHAR(V_QTY));
    dbms_output.put_line('INSERTED RATE:'||TO_CHAR(V_RATE));
    COMMIT;
    V_QTY:=0;
    V_RATE:=0;
    EXIT;
    END IF;
    IF V_QTY>0 THEN
    V_QTY:=V_QTY+RECS.TRANS_QTY;
    ELSE
    V_QTY:=0;
    V_RATE:=0;
    EXIT;
    END IF;
    --dbms_output.put_line('BAL3:'||V_QTY);
    END LOOP;
    V_QTY:=0;
    V_RATE:=0;
    END LOOP;
    CLOSE S1;
    CLOSE P1;
    OPEN CV FOR
    SELECT TRANS_NO,VOUCHER_NO,VOUCHER_TYPE,
    VOUCHER_DATE,TRANS_QTY,
    TRANS_RATE,TRANS_AMT,SHOLD_CODE,B.SHARE_CODE,B.ACC_NO,
    DTAG,TRANS_COST,SHARE_TYPE, B.SHARE_NAME,A.PUR_DATE
    FROM FIFO A, SHARES B
    WHERE A.SHARE_CODE=B.SHARE_CODE
    --AND A.SHARE_TYPE IS NOT NULL
    ORDER BY VOUCHER_DATE,SHARE_TYPE,TRANS_NO;
    END PROC_FIFO;
    Thanks and Regards,
    Luqman

    Copy from TODOEXPERTOS.COM
    Problem Description
    When running a RAM build you get the following error as seen in the RAM build
    log file:
    14:52:50 2> Updating warehouse tables with build information...
    Process Terminated In Error:
    [Oracle][ODBC][Ora]ORA-01456: may not perform insert/delete/update operation inside a READ ONLY transaction
    (SIGENG02) ([Oracle][ODBC][Ora]ORA-01456: may not perform insert/delete/update operation inside a READ ONLY transaction
    ) Please contact the administrator of your Oracle Express Server application.
    Solution Description
    Here are the following suggestions to try out:
    1. You may want to use oci instead of odbc for your RAM build, provided you
    are running an Oracle database. This is setup through the RAA (relational access
    administrator) maintenance procedure.
    Also make sure your tnsnames.ora file is setup correctly in either net80/admin
    or network/admin directory, to point to the correct instance of Oracle.
    2. Commit or rollback the current transaction, then retry running your
    RAM build. Seems like one or more of your lookup or fact tables have a
    read-only lock on them. This occurs if you modify or add some records to your
    lookup or fact tables but forget to issue a commit or rollback. You need to do
    this through SQL+.
    3. You may need to check what permissions has been given to the relational user.
    The error could be a permissions issue.
    You must give 'connect' permission or roll to the RAM/relational user. You may
    also try giving 'dba' and 'resource' priviliges/roll to this user as a test. Inorder to
    keep it simple, make sure all your lookup, fact and wh_ tables are created on
    a single new tablespace. Create a new user with the above privileges as the
    owner of the tablespace, as well as the owner of the lookup, fact and wh_
    tables, inorder to see if this is a permissions issue.
    In this particular case, the problem was resolved by using oci instead of odbc,
    as explained in suggestion# 1.

  • Default values for Insert and Update

    What is the best way to default the current sysdate for a date column on a table when doing an insert or update through a form? And related to this, what is the best way to default the current user (APP_USER) for a varchar2 column when doing an insert or update through a form?
    For these columns, I want to display them on a report, but they should be hidden on the form because I would like to have the app default the values to sysdate and APP_USER. However, when I have tried to use the table default values in "user interface defaults" and using either :APP_USER or &APP_USER or SYSDATE, it only shows this literal value on the form (item is not hidden while I debug this). It does not show the actual value I'd want, such as "user1". Does this make sense?
    Thanks for your help.
    -Reid

    I think triggers are the best device.
    Scott

  • SQL INSERT / SQL UPDATE don't work with form page, don't affect table

    The subject line says it all. No matter what I try, my updates on the form don't appear on the report page, which accesses the table. When I look at the table using SQL WORKSHOP, the changes aren't made there either. What am I missing? I have another report page and form page with a different table in the same application and updates in that table work fine. I coded them both the same. What should I be looking at?
    Steve "the n00b" in Raleigh NC

    Steve,
    How you have created the FORM page? Using FORM WIZARD? Or You have created blank page and after that you have manually created all the form items?
    If you have used WIZARD to create form page, then you can see a page process with Automatic Row Processing (DML) type. Here you need can set DML (Insert/Update/Delete) you wish to use on this form. APEX will take care of the rest.
    If there is no such process in your page, then you need to create one. You may have one process to do both (Insert and Update) and you can have two sepate processes. I prefer having two seperate page processes (after submit), one for Insert and one for Update.
    Now you can make the Insert process conditional so that it only execute when you click button - Create (Add or any similar button you have ) Also make the Update process conditional so that it only execute when you click button - Save (Update or any similar button you have )
    Just a quick note - From the above trigger, I can guess you are allowing users to enter Primary Key manually? In my opinion, Primary key should be always system generated using SEQUENCE. Users can only enter BUSINESS KEY (if any) and we should not use Business key as Primary Key.
    Good Luck :-)
    - Hari
    Edited by: Hari_639 on Oct 23, 2009 8:02 PM

  • 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

  • Report does not show updated data

    Hi,
    We are currently testing our AV implementation.
    AV server, agent and collectors are up, but the reports are not being updated.
    Reports are showing data as of Dec-22-2009, which is when the last time the unix servers (for both AV and source dbs) were rebooted.
    We can see collection is happening:
    SQL> select max(av_time) from avsys.av$rads_flat;
    MAX(AV_TIME)
    19-JAN-10 12.34.41.150446 PM
    But the dw table is not being updated:
    SQL> select max(av_time) from avsys.audit_event_fact;
    MAX(AV_TIME)
    22-DEC-09 04.58.55.255456 PM
    Does anybody have any idea?
    thank you

    hi Karun,
    correction, there are a couple of trace files after the db was restarted prior to starting AV and the collectors.
    below are the message content:
    trace file #1)
    Instance name: AVDB
    Redo thread mounted by this instance: 0 <none>
    Oracle process number: 0
    Unix process pid: 24635, image: oracle@audit1
    Dynamic strand is set to TRUE
    Running with 2 shared and 48 private strand(s). Zero-copy redo is FALSE
    trace file #2)
    Instance name: AVDB
    Redo thread mounted by this instance: 1
    Oracle process number: 30
    Unix process pid: 24922, image: oracle@audit1 (TNS V1-V3)
    *** ACTION NAME:() 2010-01-19 14:39:46.215
    *** MODULE NAME:(sqlplus@audit1 (TNS V1-V3)) 2010-01-19 14:39:46.215
    *** SERVICE NAME:(SYS$USERS) 2010-01-19 14:39:46.215
    *** SESSION ID:(213.1) 2010-01-19 14:39:46.215
    kwqmnich: current time:: 22: 39: 46
    kwqmnich: instance no 0 check_only flag 1
    kwqmnich: initialized job cache structure
    what could this mean?
    thank you!

  • How can I use multiple row insert or update into DB in JSP?

    Hi all,
    pls help for my question.
    "How can I use multiple rows insert or update into DB in JSP?"
    I mean I will insert or update the multiple records like grid component. All the data I enter will go into the DB.
    With thanks,

    That isn't true. Different SQL databases have
    different capabilities and use different syntax, That's true - every database has its own quirks and extensions. No disagreement there. But they all follow ANSI SQL for CRUD operations. Since the OP said they wanted to do INSERTs and UPDATEs in batches, I assumed that ANSI SQL was sufficient.
    I'd argue that it's best to use ANSI SQL as much as possible, especially if you want your JDBC code to be portable between databases.
    and there are also a lot of different ways of talking to
    SQL databases that are possible in JSP, from using
    plain old java.sql.* in scriptlets to using the
    jstlsql taglib. I've done maintenance on both, and
    they are as different as night and day.Right, because you don't maintain JSP and Java classes the same way. No news there. Both java.sql and JSTL sql taglib are both based on SQL and JDBC. Same difference, except that one uses tags and the other doesn't. Both are Java JDBC code in the end.
    Well, sure. As long as you only want to update rows
    with the same value in column 2. I had the impression
    he wanted to update a whole table. If he only meant
    update all rows with the same value in a given column
    with the same value, that's trivial. All updates do
    that. But as far as I know there's know way to update
    more than one row where the values are different.I used this as an example to demonstrate that it's possible to UPDATE more than one row at a time. If I have 1,000 rows, and each one is a separate UPDATE statement that's unique from all the others, I guess I'd have to write 1,000 UPDATE statements. It's possible to have them all either succeed or fail as a single unit of work. I'm pointing out transaction, because they weren't coming up in the discussion.
    Unless you're using MySQL, for instance. I only have
    experience with MySQL and M$ SQL Server, so I don't
    know what PostgreSQL, Oracle, Sybase, DB2 and all the
    rest are capable of, but I know for sure that MySQL
    can insert multiple rows while SQL Server can't (or at
    least I've never seen the syntax for doing it if it
    does).Right, but this syntax seems to be specific to MySQL The moment you use it, you're locked into MySQL. There are other ways to accomplish the same thing with ANSI SQL.
    Don't assume that all SQL databases are the same.
    They're not, and it can really screw you up badly if
    you assume you can deploy a project you've developed
    with one database in an environment where you have to
    use a different one. Even different versions of the
    same database can have huge differences. I recommend
    you get a copy of the O'Reilly book, SQL in a
    Nutshell. It covers the most common DBMSes and does a
    good job of pointing out the differences.Yes, I understand that.
    It's funny that you're telling me not to assume that all SQL databases are the same. You're the one who's proposing that the OP use a MySQL-specific extension.
    I haven't looked at the MySQL docs to find out how the syntax you're suggesting works. What if one value set INSERT succeeds and the next one fails? Does MySQL roll back the successful INSERT? Is the unit of work under the JDBC driver's control with autoCommit?
    The OP is free to follow your suggestion. I'm pointing out that there are transactions for units of work and ANSI SQL ways to accomplish the same thing.

  • How do I insert/Delete/Update a row to the DB Table from Business Component Browser

    I am using the wizard and created a project containing Business component which contain some table.
    When I run the project I could see "Oracle Business Component Browser(local)" and when I select some table from "View Object Member" I get a window displaying all the field of that table and I could browse all the info.
    My Problem is when I try to insert a new record/Delete the existing record or update some record it never gets reflected to the DataBase.
    When I try to insert a new row I did save and there was a dialog box displayed saying "Transaction ID is 1". But finally It's not reflected in the Database.
    Can some one guide me how can I do insert/delete/update operation from Oracle Component Business Browser so that the changes reflect to the Original DataBase.
    Thanks in advance
    Jitendra

    Jitendra,
    This may be a problem of caching. If you do an update,insert, or delete, and do not receive an error, then the transaction should indeed be posted.
    I assume you are hitting the Save icon after your changes if you are getting a transaction ID. Are you checking for the updates through another session (i.e. SQL*Plus), or do you then requery the View Object in the tester? Do you exit the tester and come back in and not see the changes?

  • Updateable Report : re-display collection & Update Button question

    This a sequel to a previous Updateable Report question I had.
    Varad pointed me to this doc which has been incredibly helpful .
    http://www.oracle.com/technology/products/database/application_express/
    howtos/tabular_form.html#RESTRICTIONS
    I was\am having the following issue :
    Let's zoom to the part where we create a region to display the tabular form for the previously saved collection , and drill down to the part where we create an UPDATE EMP button for that displayed collection :
    I was not able to display the collection again when I failed the validation a 2nd time. ie, clicking on the UPDATE EMP button after it displays both the errors-post validation and after displaying the collection ( of course) would return me to the previous report pre-collection creation. When I turned debug on I found out that it was not even creating the collection and was hence deleting it before displaying the subsequent page.
    So what I did differently from what the documention instructs is as follows :
    I removed the page reference on the 'branch to page' of the UPDATE EMP button. In my case, the default 'Branch to ' Page after Processing is the same page I am using for this part of the application.
    So when I remove the reference to the page number. for that button, the page is then able to re-create the collection and hence re-display the collection so I can re-fix the 2nd error ( ... and 3rd) and finally update the report .
    Just wondering if anyone else has had the same experience ?
    Thanks !

    The columns and rows have a set format for the Id, so if you know one Id you know the row and the ids of all the other columns.
    As an example, this will show the value of column 6 when you click on any column with the function call in the Element Attributes:
    Script:
    <script type="text/javascript">
    function showCol6(col){
      var col6 = document.getElementById("f06_" + col.id.substr(4,4));
      alert(col6.value);
    </script>Element Attributes:
    onclick=showCol6(this);You could also use a Named Column template, specific to this region, to include the column values directly in the function call, but I think it's best to stick with the ApEx defaults if possible.

  • Help me in creating a Trigger for Insert and Update Options

    Hi
    Please help me in creating a Trigger .
    My requirement is that after insert or update on a Table , i want to fire an event .
    I have started this way ,but doesn't know how to fully implement this .
    say i have a dept table
    CREATE TRIGGER DepartmentTrigger
    AFTER INSERT ON Dept
    BEGIN
    INSERT INTO mytable VALUES("123","Kiran");
    END DepartmentTrigger;
    Please tell me how can i put the Update option also .
    Thanks in advance .

    Please tell me how can i put the Update option also .Add "Or Update". ;-)
    Here are a few suggestions, but you definitely need to refer to the manual page that the previous poster suggested.
    CREATE OR REPLACE TRIGGER DepartmentTrigger
    AFTER INSERT Or Update ON Dept
    BEGIN
    INSERT INTO mytable VALUES(:new.Dept,'DEPT ADDED OR CHANGED');
    END DepartmentTrigger;
    The "Or Replace" means you can replace the trigger while you're developing without having to type in a drop statement every time. Just change and rerun your script, over and over until you get it right.
    Adding "Or Update" or "Or Delete" makes the trigger fire for those events too. Note, you may want seperate triggers in different scripts and with different names for each event. You have to decide if your design really does the same thing whether it's an insert or an update.
    :new.Dept is how you would refer to the changed vale of the Dept column (:old.Dept is the prior value). I changed the double quotes on the string in the VALUES clause to single quotes.
    Andy

Maybe you are looking for

  • Automatic payment program-Payment of single Invoice by two different banks.

    Hi, In APP is it possible to pay a single Invoice by more than one bank.If some one has encountered this issue,please throw your valuable suggestions.We have a client requirement. Thanks Aravind

  • Exporting MS Access (Windows) to Oracle (Unix)

    Is this possible without a third party software? If so, how can it be done?

  • Converting IDOC to XML

    Hi, I have an application where i have to convert an IDOC to XML format so that it can be handled by webmethods. I want to know how to convert IDOC to XML. I have seen that in SAP there are two port types, XML and XML HTTP. Are they used for posting

  • Convert system time into User local time.

    Hi, How to convert System time into User Local time. Are there any FMs available. Regards, Kiran

  • Insatllation CS6 ? code d'echange ?

    Mon ordi est mort hier... je cherche à installer le CS6 sur un pc de dépannage ! Installation complète réalisée... qd j'ouvre un logiciel, il me demande le numéro de série normal ! mais dans l'espace de désignation du produit il ne me propose pas Ado