Want to update data in a view based on multiple tables

Hi
I am facing a problem i want to update data in tables using a view. As that view is based on multiple tables so i am unable to update data. i came to know we can update table from view only if view is based on single table. so if anyone knows any alternative please let me know.
Thanx
Devinder

Devinder,
The table can be updated through a view based on multiple tables, if and only if the table is a "key preserved" table. Rather than explaining myself, i avoided the burden of typing by finding the material in Oracle Docs and pasting it for you :-)
If you want a join view to be updatable, all of the following conditions must be
true:
1. The DML statement must affect only one table underlying the join.
2. For an INSERT statement, the view must not be created WITH CHECK
OPTION, and all columns into which values are inserted must come from a
key-preserved table. A key-preserved table in one for which every primary
key or unique key value in the base table is also unique in the join view.
3. For an UPDATE statement, all columns updated must be extracted from a
key-preserved table. If the view was created WITH CHECK OPTION, join
columns and columns taken from tables that are referenced more than once
in the view must be shielded from UPDATE.
4. For a DELETE statement, the join can have one and only one key-preserved
table. That table can appear more than once in the join, unless the view was
created WITH CHECK OPTION.
HTH
Naveen

Similar Messages

  • Update data provider queryspecification wiith columns from multiple tables

    Hi
    I have scenario like I need  updated a queryspecificaiton with columns from multiple tables
    1. Ex:
      <bOQuery name="Query">
              <resultObjects identifier="DS0.DO1" name="A$Application_ID"/>
              <resultObjects identifier="DS0.DO2" name="A$Column_Name"/>
    A$Application_ID is from Table A and A$Column_Name from table B
    The query is not adding to dataprovier when I am trying to updated from REST API.
    Please help me.
    Thanks
    Kalyan

    Have a look at the Business Intelligence platform RESTful Web Service Developer Guide, section 3.4.7 (p. 197) - Report structure: getting and updating the structure (specifications) of a report, may be a good place to start(?). Also see KBA 1952419 - How to update the properties of a web intelligence report using RESTful web service SDK .
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • Inserting/updating data in control block based on view

    Hi!
    I`ve created a block based on a view to display data.
    I want this block to be insertable and updateable, that is I will use a on-insert/update trigger to call an insert/update procedure located in the database.
    When trying to change/insert a value in the block, the error message "Error: Can not insert into or update data in a view" pops up. I`ve tried to get rid of this error, without success.
    How can I make a data block based on a view insertable and updateable?
    My guess is that this have something to do with locking the records(there is no rowid in the view)... but I'm not sure.
    Pls advise!!

    Morten
    As well as on-update, on-insert, on-delete triggers you also need an on-lock,
    (even though it might just contain null;) otherwise the form will try to lock the view and fail.
    Actually your terminology is wrong, the block being based on a table or view is not a control block. A control block is not based on anything and has no default functionality for communicating with the database. If it was a control block, the on- triggers would not fire.

  • FRM-40602: Cannot insert into or update data in a view

    Hi all!
    I have a form based on a view and I want to get rid off this message.
    I set the properties blocks query only but it still doesn't work.
    Does someone met with this situation?
    Many thanks!

    Hello
    I've just been messing about with a similar problem. Basically, I have a view that involves a join across two tables, I have a data block in my form that's based on the view, and I've written an INSTEAD OF trigger to insert/update/delete from the two tables.
    I was getting the error message 'Cannot insert or update data in a view', and it turned out that the error was happening because the join column between the two tables was the primary key on one of the tables, but the corresponding column on the join table had no unique key on it. This meant that Oracle couldn't establish a one-to-one relationship between rows in the view and rows in the underlying tables. The column on the join table was in fact unique on that table, and adding a unique constraint on that column in the database cured the problem.
    Hope that's of use.
    regards
    Andrew
    UK

  • Update data from a view

    Hi,
    trying to update data from a view with:
    - Company (table)
    - Products (table)
    In a form, the user wants to update
    e.g: both products.product_name and Company.company_name.
    Is there a way to update a view records built on 2 tables ?
    Any idea will be really appreciated
    Thks

    An other question on INSTEAD OF Trigger:
    Base Tables:
    1.
    SQL> desc pcs_companies;
    Name Null? Type
    COMPANY_ID NOT NULL NUMBER(12)
    COUNTRY VARCHAR2(350)
    COMPANY_NAME VARCHAR2(320)
    COMPANY_PHONE VARCHAR2 (320)
    COMPANY_FAX VARCHAR2(320)
    COMPANY_URL VARCHAR2(150)
    UPDATED_DATE DATE
    2.
    SQL> desc pcs_individuals;
    Name Null? Type
    INDIVIDUAL_ID NOT NULL NUMBER(12)
    COMPANY_ID NUMBER(12)
    FIRST_NAME VARCHAR2(320)
    LAST_NAME VARCHAR2(320)
    LOB VARCHAR2(300)
    JOB_ROLE VARCHAR2(300)
    TITLE VARCHAR2(300)
    GENDER VARCHAR2(3)
    EMAIL VARCHAR2(720)
    FAX VARCHAR2(720)
    PHONE_NO VARCHAR2(720)
    UPDATED_DATE DATE
    COUNTRY VARCHAR2(150)
    ADDRESS_1 VARCHAR2(720)
    ADDRESS_2 VARCHAR2(720)
    ADDRESS_3 VARCHAR2(720)
    CITY VARCHAR2(720)
    3. pcs_individuals.COMPANY_ID = FK, ref pcs_companies.
    4.
    SQL> CREATE VIEW V_PCS_COMPANY_IND
    AS
    SELECT
       i.INDIVIDUAL_ID,
       c.company_id,
       c.country,
       c.Company_name,
       c.company_phone,
       i.Company_id indiv_company_id,
       i.gender,
       i.first_name,
       i.last_name,
       i.lob,
       i.job_role,
       i.title,
       i.email_address,
       i.fax,
       i.phone_no ,
       i.address_1,
       i.address_2,
       i.address_3,
       i.city
    FROM
      pcs_individuals i,
      pcs_companies c
    WHERE
      i.company_id = c.company_id
    5.
    CREATE OR REPLACE TRIGGER PCS_ADMIN.PCS_COMP_IND_UPDATE_TR
    INSTEAD OF UPDATE ON PCMS_ADMIN.V_PCS_COMPANY_IND
    FOR EACH ROW
    begin
    update PCS_COMPANIES
    set
         Company_name = nvl(:new.company_name,company_name),
         company_phone = nvl(:new.company_phone,company_phone)
    where company_id = :new.company_id;
    update PCS_INDIVIDUALS
    set
         gender = nvl(:new.gender,gender),
    first_name = nvl(:new.first_name,first_name),
         last_name = nvl(:new.last_name,last_name),
         lob = nvl(:new.lob,lob),
         title = nvl(:new.title,title),
         email_address = nvl(:new.email_address,email_address),
    phone_no = nvl(:new.phone_no,phone_no),
         fax = nvl(:new.fax,fax),
         country = nvl(:new.country,country),
         address_1 = nvl(:new.address_1,address_1),
         address_2 = nvl(:new.address_2,address_2),
         address_3 = nvl(:new.address_3,address_3),
         city = nvl(:new.city,city)
    where company_id = :new.company_id;
    end PCMS_COMP_IND_UPDATE_TR;
    6.
    CREATE OR REPLACE TRIGGER PCS_ADMIN.NEW_COMPANY_ID_INSERT
    INSTEAD OF INSERT ON PCS_ADMIN.V_PCS_COMPANY_IND
    DECLARE
    ID number;
    BEGIN
    INSERT INTO pcs_companies (org_id)
    select v_pcs_comp_id_seq.nextval
    into ID
    from dual;
    :new.company_id = ID;
    INSERT INTO pcs_individuals (company_id)
    select v_pcs_comp_id_seq.nextval
    into ID
    from dual;
    :new.company_id = ID;
    end;
    My question
    On point 6:
    Assumption:
    - Company_id is PK of pcs.Company and FK in pcs.individuals
    - It should be feed by sequence (v_pcs_comp_id_seq)
    Now how can i insert the same value for company_id (current.v_pcs_comp_id_seq) in both pcs_companies and pcs_individuals ? I've tested it in the above INSTEAD OF Trigger.It failed.
    Thks for any advice,
    lamine

  • I want to update date field in oracle table using database adaptor

    Hi Guys,
    I want to update date in oracle table field which is 'DATE' type , but i am getting following error.
    Pure SQL Exception.
    Pure SQL Execute of update crp3apps.IFACE_SO_DATE_CHANGES set PROCESSED_DATE=? where CTRL_ID=? failed. Caused by java.sql.SQLException: ORA-01830: date format picture ends before converting entire input string
    The Pure SQL option is for border use cases only and provides simple yet minimal functionality. Possibly try the "Perform an operation on a table" option instead.
    </summary>
    </part>
    - <part name="detail">
    <detail>
    ORA-01830: date format picture ends before converting entire input string
    </detail>
    i am formated the date using following code and assigned to one variable.
    ora:formatDate(ora:getCurrentDateTime(),'dd-MMM-yyyy hh:mm:ss ')
    this is update query
    update crp3apps.IFACE_SO_DATE_CHANGES set PROCESSED_DATE=#date where CTRL_ID=#id
    Please provide solution.
    regards
    janardhan

    The thing is that XSLT often doesn't deliver the functionality required when it comes to times.
    You suggest appening "Z" to the time but this means that the time is now in UTC time. What if the system from where the date is being converted is running in NZ using local time? Other systems that recieve the date (and correctly handle the time zone) will now have a time that is out by a number of hours.
    You often can't ignore the time zone (drop the 'Z') as if you send the time to a system it has to either assume the time is local to it (which may not be the case... the other system coudl be in a different time zone) or assume the time is UTC (I think crossfire does this by default).
    Typically can't just append a time zone (e.g. +11:00) either as many places have daylight savings so the value to appended is variable (you then need some way of determining what the value is... either Java Embedding or a Service).
    As you mention it does depend on the use case but in many circumstances using Jaba Embedding, not as suggested above but with the appropriate Java.util.Calendar classes, is the best way to handle date and time in BPEL. Even still you need to ascertain the format of times external to the system and ensure you parse them correctly.
    ANd even if you do all this you can still run into problems. I've seen a real world example where two systems which both handled time zones correctly and had previously been working together for quite a while, satrted reporting different times. It turns out that only one of them had had the most recent Java Time Zone patches applied and there had been a change in the dates for daylight savings here (Australia). Be warned!

  • I want to retrieve data from p0001-PLANS based on the below condition,

    Hi,
    I want to retrieve data from p0001-PLANS
    based on the below condition
    select stext from hrp1000 where plvar = '01' and otype = 'S' and objid = p0001-plans and begda GE pn-begda and endda LE pn-endda.
    Thanks,
    Rama.

    Hi
    Based on the Query you have specified thoise are stoerdin an Internal table- then
    select stext from hrp1000 into table t_hrp where plvar = '01' and otype = 'S' and objid = p0001-plans and begda GE pn-begda and endda LE pn-endda.
    The check table for this PLANS is T528B .
    if t_hrp[] is not intitial.
    select * from t528B intot table t_528 where plans eq t_hrp-plans.
    endif.
    Now you can get the PLANS data.
    Refer to the Text tbale for PLANS -  T528T
    To get the TEXTS -
    if t_hrp[] is not initial.
    select * from T528T into table t_528T where plans eq t_hrp-plans.
    endif.
    Regards
    Lekha

  • Can I update datas of Power Query after making relation tables in Power Pivot ?

    Can I update datas of Power Query after making relation tables in Power Pivot ?
    I want to update datas at day by day to viewing today's graph by Power View on Excel.
    Power Query use to transform web site to Power Pivot data model table.
    Power Pivot use to making relasing tables, and making measuers.
    Regards,
    Yoshihiro Kawabata.

    Hi Yoshihiro,
    Can you share an example of the things you are doing in Power Pivot? There are some operations that prevent the query from being refreshed in Power Query; this is not ideal so we are currently working on fixing it.
    Thanks for your feedback.

  • Strange behaviour of view based on several tables join with union all

    Dear fellows we r facing a strange problem we have a view based on several tables joined by union all ,when we issue an ordered query on date,rows returned are unusually different than they should be .
    Is oracle has some special behaviour for view based on union all ?
    I m using oracle 8.1.6 on windows 2000
    Kashif Sohail

    Did you ever solve this problem? I have two select statements based on 4 tables and 3 views using about 5 more tables. When I execute each select individually I get exactly what is expected. When I UNION ALL both selects together, I get "no rows returned", however when I UNION them I get exactly what is expected. I should get the same answer for both UNION ALL and UNION. The two select statements are identical, except for one column where I changed the constant to be different. Any thoughts?

  • Update a field in view, based on change in one of it's tables.

    Hi,
    I have created a Maintenance view based on three DB tables.
    My requirement is if i change data in one the database tables the view should get automatically updated with the new data.
    Could anyone please soleve my issue, points are definite.
    Thanks and regards,
    raghavendra goutham p.

    Hi,
       any changes to the database field value will
       automatically gets reflected in view .
       please check it.
    Regards
    Amole

  • Updating data throug a view in forms

    Hi,
    How is it possible to update data through a updateable view, when there is no rowids in a view? Can i define primary key some how to the form instead of rowid?
    Regards Tarja

    yes, you can choose one (or more) item then set the PRIMARY KEY property to yes.
    Francois

  • View link between view based on entity(table) and view based on stored proc

    I've created a view based on a stored procedure. I need to link this view to a view based on an entity which is based on a table.
    I can create the view without issue, but when I attempt to run the application module that contains the relationship I get this error:
    (oracle.jbo.InvalidOperException) JBO-26016: Cannot set user query to view "SalesentityModuleApiView2" because it is a destination in a view link
    One thing that may be notable about this is that this view started out based on a database view. I later overrode the select related methods using the example here:
    http://download-east.oracle.com/docs/html/B25947_01/bcadvvo008.htm
    Any ideas? I will gladly post some code if someone will let me know what might help diagnose this.

    Hi,
    I solved my problem with adding transient field, and changing the value of it (true | false) on set method of field that can be changed so I can get which row was updated. What exactly do you mean when you say not updateable, I'm using a vo with no entity, and I can add, remove rows, in fact I think it's a good solution because I don't want to write to database immediately.

  • Want to update a column with  different column of same table

    I have a table TEST_CDR which is having 250 millions records also having partition by hash.
    there are two column in this table ID and CDR_ID want to update ID in CDR_ID but it take too much time like 24 hours or more.
    please suggest me a simple way.

    Hi,
    You can try this. but be careful about your backups and go through CTAS,nologging and parallel concepts...
    Please refer this link.
    http://www.dba-oracle.com/t_fast_batch_updates_ctas.htm
    http://www.dba-oracle.com/t_nologging_append.htm
    http://www.dba-oracle.com/t_efficient_update_sql_dml_tips.htm
    http://eriglen.blogspot.in/2011/08/ctas-create-table-as-select-with.html
    1.CTAS with nologging and parallel..
    SQL> create table test_cdr_1(id,cdr_id) nologging parallel as select id,id from test_cdr;
    2.rebuild indexes, triggers and constraints to test_cdr_1
    3.rename test_cdr to bkup_test_cdr;
    4.rename test_cdr_1 to test_cdr;
    Regards,
    ragunath.

  • I want to insert data into a gta from a nested table

    Hi,
    I want to insert data into a global temporary table from nested table.
    How do i do it?

      cursor cc is select * from t1;
       TYPE temp_rec_tab IS TABLE OF temp_rec_tap_cur%ROWTYPE;
       TYPE rec_num_tab1 is table of temp_records_tap.record_num%type;
       v_test_tab     temp_rec_tab;
    ----   v_rec_num      num_tab;
       v_rec_num rec_num_tab1;  
       v_filename     temp_records_tap.file_name%TYPE;
       v_error_code   tap_reject.ERROR_CODE%TYPE;
       v_rej_value    tap_reject.field_rej%TYPE;
       v_count        NUMBER;
    BEGIN
       OPEN cc;
       LOOP
          BEGIN
             FETCH cc
             BULK COLLECT INTO v_test_tab LIMIT 1000;
             FORALL i IN v_test_tab.FIRST .. v_test_tab.LAST SAVE EXCEPTIONS
                INSERT INTO tt2
                     VALUES v_test_tab (i)
                  RETURNING       record_num
                BULK COLLECT INTO v_rec_num;
          EXCEPTION
             WHEN OTHERS
             THEN
          NULL;
          END;
          EXIT WHEN temp_rec_tap_cur%NOTFOUND;
       FORALL i in  v_rec_num.first..v_rec_num.last
       INSERT INTO record_num_session values v_rec_num(i); ------- v_num(i) INVALID IDENTIFIER ??????
       END LOOP;
    END;

  • Best way to remove duplicates based on multiple tables

    Hi,
    I have a mechanism which loads flat files into multiple tables (can be up to 6 different tables) using external tables.
    Whenever a new file arrives, I need to insert duplicate rows to a side table, but the duplicate rows are to be searched in all 6 tables according to a given set of columns which exist in all of them.
    In the SQL Server Version of the same mechanism (which i'm migrating to Oracle) it uses an additional "UNIQUE" table with only 2 columns(Checksum1, Checksum2) which hold the checksum values of 2 different sets of columns per inserted record. when a new file arrives it computes these 2 checksums for every record and look it up in the unique table to avoid searching all the different tables.
    We know that working with checksums is not bulletproof but with those sets of fields it seems to work.
    My questions are:
    should I use the same checksums mechanism? if so, should I use the owa_opt_lock.checksum function to calculate the checksums?
    Or should I look for duplicates in all tables one after the other (indexing some of the columns we check for duplicates with)?
    Note:
    These tables are partitioned with day partitions and can be very large.
    Any advice would be welcome.
    Thanks.

    >
    I need to keep duplicate rows in a side table and not load them into table1...table6
    >
    Does that mean that you don't want ANY row if it has a duplicate on your 6 columns?
    Let's say I have six records that have identical values for your 6 columns. One record meets the condition for table1, one for table2 and so on.
    Do you want to keep one of these records and put the other 5 in the side table? If so, which one should be kept?
    Or do you want all 6 records put in the side table?
    You could delete the duplicates from the temp table as the first step. Or better
    1. add a new column WHICH_TABLE NUMBER to the temp table
    2. update the new column to -1 for records that are dups.
    3. update the new column (might be done with one query) to set the table number based on the conditions for each table
    4. INSERT INTO TABLE1 SELECT * FROM TEMP_TABLE WHERE WHICH_TABLE = 1
    INSERT INTO TABLE6 SELECT * FROM TEMP_TABLE WHERE WHICH_TABLE = 6
    When you are done the WHICH_TABLE will be flagged with
    1. NULL if a record was not a DUP but was not inserted into any of your tables - possible error record to examine
    2. -1 if a record was a DUP
    3. 1 - if the record went to table 1 (2 for table 2 and so on)
    This 'flag and then select' approach is more performant than deleting records after each select. Especially if the flagging can be done in one pass (full table scan).
    See this other thread (or many, many others on the net) from today for how to find and remove duplicates
    Best way of removing duplicates

Maybe you are looking for