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

Similar Messages

  • 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

  • Creating a external content type for Read and Update data from two tables in sqlserver using sharepoint designer

    Hi
    how to create a external content type for  Read and Update data from two tables in  sqlserver using sharepoint designer 2010
    i created a bcs service using centraladministration site
    i have two tables in sqlserver
    1)Employee
    -empno
    -firstname
    -lastname
    2)EmpDepartment
    -empno
    -deptno
    -location
    i want to just create a list to display employee details from two tables
    empid firstname deptno location
    and same time update  in two tables
    adil

    When I try to create an external content type based on a view (AdventureWorks2012.vSalesPerson) - I can display the data in an external list.  When I attempt to edit it, I get an error:
    External List fails when attached to a SQL view        
    Sorry, something went wrong
    Failed to update a list item for this external list based on the Entity (External Content Type) 'SalesForce' in EntityNamespace 'http://xxxxxxxx'. Details: The query against the database caused an error.
    I can edit the view in SQL Manager, so it seems strange that it fails.
    Any advice would be greatly GREATLY appreciated. 
    Thanks,
    Randy

  • Sender JDBC.....pick data from table view?

    Hi Experts,
    working on JDBC for first time, so have few questions.
    data base guys want to create a table view and we need to pick the data from table view.
    my question is can we import the structure form data view?
    if i am not able to import, so i need to create the structure same as in data base table view and is it case sensitive?
    they dont want to update the data base table view, very time the SQL query will pick all the records form data base.
    the records will be less then 10,000.
    my question is as we are not updating the table view, what we need to write in update query as it is mandatory?
    Regards,
    Chinna

    Hello,
    i hope below option help in update query
    In place of the SQL statement, you can also enter <TEST>. Once the data determined from Query SQL Statement has been successfully sent, the data in the database remains unaltered.
    This is recommended if the data has not only been read, but also changed by a stored procedure entered under Query SQL Statement.

  • Is possible to represent data from a view in MapViewer?

    I have tried to represent data from a view instead a table with the Java-Beans API but I couldn't beacause it doesn't represent any geometry referenced by the view. I think it should be implemented because is very common to use views. Are there any way to represent them in MapViewer?
    Thanks.

    Like a table, you also need to register the view in spatial metadata (user_sdo_geom_metadata). Did you register the view and its spatial column there?

  • Why do we get the data from a view to a report.

    hi
    why do we get the data from a view to a report. is it possible to get the data from a view in all the cases?

    hi Jyotssna,
      Suppose you are planning to get the data from multiple tables then you got to specify seveal condtions and make use of joins which results in poor performance in fetching the data . In order to improve the performance we make use of views where the conditions of different tables are defined and the data is fetched accordingly.
    Regards,
    Santosh

  • Error while updating data from PSA to ODS

    Hi Sap Gurus,
    I am facing the error while updating data from PSA to ODS in BI 7.0
    The exact error message is:
    The argument 'TBD' cannot be interpreted as a number
    The error was triggered at the following point in the program:
    GP44QSI5RV9ZA5X0NX0YMTP1FRJ 5212
    Please suggest how to proceed on this issue.
    Points will be awarded.

    Hi ,
    Try to simulate the process.That can give you exact error location.
    It seems like while updating few records may be no in the format of the field in which it is updated.
    Regards
    Rahul Bindroo

  • Can we get data from business views  in CR 2008/XI?

    Hi All,
    Can we get data from business views  in CR 2008/XI?
    If its possible, pls let us know how to get connect with Business View in both of these versions and what is the tool that we have to use to create Business Views.
    Thank you,
    Krishna Pingali

    Hi Krishna,
    Crystal Reports/BusinessObjects Enterprise ( BOE ) Business Views can only be created using the BV build which comes with BOE and installed using the Work Station installer for BOE. for both XI and 2008.
    You cannot mix these two versions on the same PC not can one talk to the other, the BV designer must match the same version as BOE. XI ( version 11.0 ) is no longer available but if you mean XI R2 ( version 11.5 ) then it still is.
    It's not completely clear which Business View you are referring to? BOE has a Business View Designer so not sure if this is just a naming problem or not? If you are referring to the BOE Business View Designer then the above is true. If your reference is about some other BV designer or data source then you need to clarify.
    Contact our Sales department for pricing and availability.
    Thank you
    Don

  • Update data from cube to cube in BW 3.5

    Dear Experts,
            Can we update data from one cube to another cube in BW 3.5. i tried it, I created the connection between two cubes as i did in ods to cube through update rules but there is no option like in ods to send the data(update dso data to data targets).Please help me on this.

    hi arvind,
           Thanks, but i have some doubt again, i did it and also data transfered to the second cube, but after creating the connection i went to bi7 in infosource and there i found that cube name starting with 8(cube name), but my question is can i do it in bw3.5 without going to rsa1.

  • Update data from ODS to ODS with infopackage selection

    Hi,
    I am trying to update data from one ODS to another ODS with selection criteria in InfoPackage which is created manually.For Full load I can give selection criteria in InfoPackage. When I initialize data Selection is greyed out even selections for Full load exists. Please advise me how to give selections for delta loads from ODS to ODS loads.
    Thanks in advance.
    Ram

    Once you started an ODS as destination in FULL mode from a DS you cannot get back.
    So if you want to update from ODS to ODS using Change Log but considering only some data records you could create an Update Routine with a Start Routine that DELETES undesired records (e.g. DELETE DATA_PACKAGE WHERE ...) and then start an Init-Delta Loading.
    Hope it helps
    GFV

  • How Can i Read data From Maintainance View

    I Want read data from Maintainance View. i written select query
    SELECT *
    FROM J_1yyyyV
    INTO TABLE GT_BUSPLACE.
    WHERE BUPLA = LV_BUPLA.
    this is giving following error
    "J_1yyyyV" is not defined in the ABAP Dictionary as a table,
    projection view, or database view.
    Can you help me Please.
    Thanks in Advance.
    Regards,
    Raj.

    Hi raj,
    maintainance view is a nothing but combinations of table using join on some fields..
    see the relation ship between the joins..
    if you want to write selection query ..go to se11 -->enter view name >and open tab>
                    Table/Join  conditions--> see the table's involved and join conditons between tables.
    and write the select query same as like the Table/Join  conditions in se11..now you can acheive the
    table maintainance fields..
    Prabhudas

  • How to extract data from maintenance view

    Hi experts,
    How can I select the data from maintenance view. As you know select query doesn't work on the maintenance view. And View name will be known at run time only.
    Thanks
    Yogesh Gupta

    > Let me tell you that I am a SAP certified ABAP consultant having experience of 4.5 years.
    I suspect that we will be hearing more comments about that.
    > Whatever question I asked can't be replied with the basic training (if yes please tell me even one).
    Debugging a macro?
    Another one => FM or BAPI to create the Activity Group in 4.0B No answer is possible? You have to be joking!
    And in How to get email ID fo a SAP user you obviously didn't even try Graham's answer!
    > I closed some of the answered questions since I didn't get the answers for them for a long time and SDN site doesn't allow to keep more than 10 questions open.
    The "comment field" is not mandatory. You don't need to flood the forum with your questions again.
    > I do respect your  concerns but I have no intention to abuse this site as it has been very helpful for me.
    That is the most important part. Thank you. But you seem to be unaware of the "search" functionality.
    If you can imagine that you are not the first person to ask a certain question, then you can be sure that someone else already has and you can find the answers on your own. If you still have doubts, then ask a specific question providing the details.
    Based on your other questions, you are on release 4.0B. Is that still correct?
    Cheers and thanks for responding,
    Julius
    Edited by: Julius Bussche on Jan 23, 2009 12:06 AM

  • How to retrieve data from a view.

    HI,
    I want to retrieve the values of the <b>Field MNTXT from the view V_T530</b>.
    Please let me know how i can retrieve data from this view.The Select statement doesnt work on a view.
    Regards,
    Bhavika

    Hi kumar,
    By using select stattement you can fetch from view. 
    Here viaufkst is view.
    For it is working. please check.
    select (g_selfields_tab) from viaufkst
              into corresponding fields of table order_itab
                       for all entries in order
                              where                "(g
                              aufnr in order and
                              equnr in equip and
                              priok in prior and
                              iphas = '3' and
                              ilart in acttyp and
                              qmnum in notif and
                              werks = plant and
                              auart in ortyp and
                              getri in date.
    please try.
    with Regards,

  • How to extraxct  data from a view.

    hi,
        i'm tying to extrct data from a view vbdka, with select. but i;m getting a syntax error that it anot a DB Table or DB view, pls tell me how to extract data from that view.
    thanks.

    hi,
    just check out if u have declared the table or not n see if it is not a structure also
    madhuri.

  • How to extract data from generic view and function module

    hi experts,
    can anybody give me the steps to extract data from generic view and  functon modules.
    thanks and regards
    venkat

    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/a0f46157-e1c4-2910-27aa-e3f4a9c8df33
    https://websmp103.sap-ag.de/~sapidb/011000358700007535452002
    Hope it Helps
    Chetan
    @CP..

Maybe you are looking for