Insert into other table from form

Hi All,
I have created a data block with view as a data source. I need to save the data from a form to some other table.
I have tried using INSTEAD OF Trigger. howeverwhen I try to save, getting an error : ORA-01445 cannot select ROWID from a join view without a key-preserved table.
I appreciate any suggestions on it.
Thanks and Regards
Sai

Sorry, it looked at first as if you wanted help on the problem you encountered. After reading again your response to Zaibiman I see that you were just tricking us with the detailed explanation of the error.
To insert into a table other than the one you queried, use the on-insert trigger.
However, an Instead Of trigger on the view is usually the best method. If you have set the key mode, defined a primary key item and removed any references to rowid, as per Zaibiman, then it should work. You'll need your own locking method if the view uses Group By or Distinct.

Similar Messages

  • Record is not inserting into the Table thourgh forms 10g

    Hi All,
    I have the form built in 10g(10.1.2.0.2).
    Basically the form has 2 blocks.
    Block 1 with only one item, where we enter some value and hit enter(this will navigate to block2 and execute the query).
    Block 2(tabular) will fetch the records. Now this block2 have 3 columns(caseid, userid, date).
    Now when I insert a new record, I just need to enter the caseid only. And userid and date have to be automatically populated.
    I can populate the USERID and DATE fields.
    And when I enter some value in caseid item of block 2, and then do Control+S(to insert the record and Save the transaction),
    i get the message saying FRM-40400: Transaction complete: 1 records applied and saved.
    But when I query again for the same, I dont se the record inserted into the table.
    Why is this happening?
    Help please...

    @ Inol
    There is no promary or foriegn key relation ship. The form is fetching records from just one table. As I said block1 has col1. and Block2 has col2,3,4.
    @Andreas
    Yes I did select * from table, select count(*) from table in SQL*Plus. Nothing is inserted.
    And one thing I have to tall here is, I have a ON-INSERT trigger in block2.
    The code in ON-INSERT trigger is
    --  :BLOCK2.DATE := TO_DATE(:DATE,'DD-MON-YYYY') ;
    /* commented since I was populating date by assigning $$DATETIME$$ to the Initial value property of the data item. */
    :BLOCK2.SOURCE_CASE := :BLOCK1.SOURCE_CASEID;Forgot to tell you,
    Since I was inserting the record from block2(3 columns), to the table which has 4 columns, there is another item in block 2 which has the visible property No.
    So the block 2 has 4 columns. And the hidden column will hold the value that is in the item of block1. This is what i'm pushing in the ON-INSERT trigger.
    Edited by: Charan on Sep 20, 2011 1:51 PM

  • Insertion into local table from remote table with contains clause

    Hi all,
    We are tasked to insert some rows into our database from another database. We tried to use DBLinks to link the 2 databases and were able to use Select statements to filter out the data that we need to insert into our database.
    These statements take the form of: Select * from RemoteTable where contains@RemoteLink(IndexColumn, 'car')>0;
    where RemoteLink is the DBLink that we have created.
    However Oracle gave us an error (ORA-00949: illegal reference to remote table) when we tried to insert the dataset from the above statement into our local table. We used the following statement in doing so: Insert Into LocalTable (Select * from RemoteTable where contains@RemoteLink(IndexColumn, 'car')>0);
    Even if we use Create Table, Oracle gave us the same error when we tried to push the data from the Select Statement into the new table.
    Could anyone advise us whether it is possible to insert such data into a local table? And if som what is the proper way of doing it?
    Many thanks to any advises.

    Hi,
    there is document 261741.1 on Metalink. This states explicitly that it is not possible to invoke remote user-defined operators, and contains is such. The solution given in the article is to create a wrapper function on the remote site and this one calling in stead of contains.
    Herald ten Dam
    htendam.wordpress.com

  • How to insert into 2 tables from the same page (with one button  link)

    Hi,
    I have the following 2 tables....
    Employees
    emp_id number not null
    name varchar2(30) not null
    email varchar2(50)
    hire_date date
    dept_id number
    PK = emp_id
    FK = dept_id
    Notes
    note_id number not null
    added_on date not null
    added_by varchar2(30) not null
    note varchar2(4000)
    emp_id number not null
    PK = note_id
    FK = emp_id
    I want to do an insert into both tables via the application and also via the same page (with one button link). I have made a form to add an employee with an add button - adding an employee is no problem.
    Now, on the same page, I have added a html text area in another region, where the user can write a note. But how do I get the note to insert into the Notes table when the user clicks the add button?
    In other words, when the user clicks 'add', the employee information should be inserted into the Employees table and the note should be inserted into the Notes table.
    How do I go about doing this?
    Thanks.

    Hi,
    These are my After Submit Processes...
    After Submit
    30     Process Row of NOTES     Automatic Row Processing (DML)     Unconditional
    30     Process Row of EMPLOYEES     Automatic Row Processing (DML)     Unconditional
    40     reset page     Clear Cache for all Items on Pages (PageID,PageID,PageID)     Unconditional
    40     reset page     Clear Cache for all Items on Pages (PageID,PageID,PageID)     Unconditional
    40     reset page     Clear Cache for all Items on Pages (PageID,PageID,PageID)     Unconditional
    40     reset page     Clear Cache for all Items on Pages (PageID,PageID,PageID)     Unconditional
    50     Insert into Tables     PL/SQL anonymous block     Conditional
    My pl/sql code is the same as posted earlier.
    Upon inserting data into the forms and clicking the add button, I get this error...
    ORA-06550: line 1, column 102: PL/SQL: ORA-00904: "NOTES": invalid identifier ORA-06550: line 1, column 7: PL/SQL: SQL Statement ignored
         Error      Unable to process row of table EMPLOYEES.
    Is there something wrong with the pl/sql code or is it something else?

  • Record not inserting into the table through Forms 10g

    Hi all,
    I have created a form in 10g(10.1.2.0.2) based on just one table that has 4 columns(col1, col2, col3, col4).
    Here col1, col2 and col3 are VARCHAR2 and col4 is date and all the columns are not null columns(There are no primary and foriegn key constrains, which means duplicates are allowed).
    My form contains 2 blocks where block 1 has one text item (col1) and 3 buttons (Delete, Save, Exit).
    And block2 is a database block and has col2,col3,col4 which are in tabluar layout frame displaying 10 records.
    When the form is opened the cursor has to be in block1.col1 for querrying. Here i enter a value in col1, and then when I click on col2 in the block2, then I put execute_query in new_block_instance of block2, which displays the records.
    The block2 properties are not updatable, insertable and query is allowed.
    Everything is working good until here. But here in the block2 when I want to insert another record into the table, by navigating all the way down to the last empty record and entering the new values for col2, col3 and col4 And then Ctrl+S will display the message "*FRM-40400: Transaction complete: 1 record applied and saved.*" But actually the record is not inserted into the table.
    I also disabled the col4 by setting the Enabled property to No, since while inserting new record the date have to be populated into it and it shouldnt be changed by the user. And im populating the sysdate into the new record by setting Intial Value property to *$$DATE$$*.
    And another requirement which I could not work arround here is that, the col3 also should be populated with the username of the user while inserting.
    please help me...

    Hi Sarah,
    I do not want to update the existing record. So I kept Udate Allowed to No in property palette for the items in block2.
    Do I have to do this property at block level also?
    I'm inserting a new record here.
    Edited by: Charan on Sep 19, 2011 8:48 AM

  • How to insert into a table from 3 tables?

    Hello,
    How to insert into a table getting values from 3 different tables?
    For example table_A has col_1 to col_10.
    I want to insert into table_A,
    values: col_1 to col_4 are from table_B,
    col_5 is from table_C,
    col_6 to col_10 are from table_D.
    Thanks!

    Normally, you'd do this by joining B, C, and D together. In the simplest case, something like
    INSERT INTO A( col1, ... col10 )
      SELECT B.col1, ..., B.col4,
             C.col5,
             D.col6, ..., D.col10
        FROM B,
             C,
             D,
       WHERE B.someKeyColumn = C.someKeyColumn
         AND C.anotherKeyColumn = D.anotherKeyColumnYou'd have to know how the data in B, C, and D relate to fill in the WHERE clause. This basically tells Oracle how to match the data in a particular row in B with the data in a particular row in C with the data in a particular row in D.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Apex Application inserting into two tables from two regions in a page

    Hey Guys,
    Fairly new to apex like two days. So please bare with me. I am using apex 4.0.2.00.07.
    I have a page with two regions. The first region has only one row and I have no problems accessing it and inserting those values into the table this is what I used to access one column from that one row APEX_APPLICATION.G_F03(1)
    The second region is an interactive report, to which I have managed to add a checkbox and a textbox.
    1)So if a checkbox has been checked off the row should be inserted
    2) if the textbox has been entered it should replaceone of the values.
    My question is how to access the second region? I started a loop based on the rows in the collection but that is as far as I got.
    FOR idx IN 1..l_collectionTable_name
    loop
    end loop
    Any help would be greatly appreciated?
    Thank you
    Edited by: Aj05 on Aug 2, 2012 2:10 PM

    Hi Phil I used the following code
    <cfquery name="qArrivalDates" datasource="rayannesql">
    SET NOCOUNT ON
    INSERT INTO booking (book_made, book_checkin_date,
    book_checkout_date, book_adults, book_children)
    VALUES('#FORM.book_made#','#FORM.book_checkin_date#','#FORM.book_checkout_date#','#FORM.bo ok_adults#','#FORM.book_children#')
    SELECT SCOPE_IDENTITY() AS theNewId;
    SET NOCOUNT OFF
    </cfquery>
    <cfquery name="qArrivalDates" datasource="rayannesql">
    INSERT INTO Customer( firstname, lastname, address, address2,
    city, state, postalcode, country, phone, mobile, email, notes)
    Values (#qArrivalDates.theNewId# '#FORM.firstname#',
    '#FORM.lastname#', '#FORM.address#', '#FORM.address2#',
    '#FORM.city#', '#FORM.state#', '#FORM.postalcode#',
    '#FORM.country#', '#FORM.phone#', '#FORM.mobile#', '#FORM.email#',
    '#FORM.notes#' )
    </cfquery>
    When I tried to complete the form, I got the following error
    Macromedia][SequeLink JDBC Driver][ODBC
    Socket][Microsoft][SQL Native Client][SQL Server]Incorrect syntax
    near 'Fred'.
    The error occurred in
    C:\Inetpub\wwwroot\rayanne\customerinsertsql.cfm: line 16
    14 : <cfquery name="qArrivalDates"
    datasource="rayannesql">
    15 : INSERT INTO Customer( firstname, lastname, address,
    address2, city, state, postalcode, country, phone, mobile, email,
    notes)
    16 : Values (#qArrivalDates.theNewId# '#FORM.firstname#',
    '#FORM.lastname#', '#FORM.address#', '#FORM.address2#',
    '#FORM.city#', '#FORM.state#', '#FORM.postalcode#',
    '#FORM.country#', '#FORM.phone#', '#FORM.mobile#', '#FORM.email#',
    '#FORM.notes#' )
    17 : </cfquery>

  • Bulk Insert into a Table from CSV file

    I have a CSV file with 1000 records and i have to insert those records into a table.
    I tried for Bulk Insert command and Load data infile command but it throws error.
    Am using Oracle 10g Express Edition.
    I want to achieve it thru query command and not by plsql procedures
    Please send me query syntax for this problem. . . .
    Thanks in Advance,
    Hariharan ST.

    Hi
    If you create an external table that points to your csv file you will then be able populate your table from a query.
    See: http://www.astral-consultancy.co.uk/cgi-bin/hunbug/doco.cgi?11210
    Hope this helps

  • Insert into SAP table from external program

    Hi Gurus,
    I need to perform an insert of several records into a couple of SAP tables from an external program.
    Do you know of an RFC (if it is remote enabled the better) that allows me to specify the table and records to perfom an insert?
    Many thanks
    Mauricio Pego

    I don't know ABAP and wanted to avoid writing my own function if one standard exists.
    My requirement stands like this, I have a few z tables that need to populate from my C# application by use of the .Net connector.
    I haven't found a BAPI or RFC that allows me to add records to any table, but I don't know all the RFCs.
    May be one of you passed throu this already.
    Mauricio

  • Field != then Insert Into Other Table

    Hi,
    I cannot figure out how to create a trigger that will insert data based on if a old.field != new.field. If the field was changed in
    one table tbl_test then insert that record into the other table tbl_test_history. This is a little different since I want to insert a record if a update
    took place. The update will still take place in tbl_test but I want a insert to take place in tbl_test_history.
    CREATE OR REPLACE TRIGGER AU_INSERT_TEST_HISTORY
      AFTER UPDATE
      ON TBL_TEST   FOR EACH ROW
    WHEN (
        OLD.Orange != NEW.Orange
    OR OLD.Apple != NEW.Apple
    BEGIN
    INSERT INTO TBL_TEST_HISTORY
    (ORANGE,
      APPLE
      BANANA,
      GRAPE
      select ORANGE,
             APPLE
             BANANA,
             GRAPE
    FROM TBL_TEST, TBL_TEST_HISTORY
      WHERE  TBL_TEST.PK_TEST_ID = TBL_TEST_HISTORY.PK_TEST_ID;
    END AU_INSERT_TEST_HISTORY;
    /I will have a separate trigger that will insert records from tbl_test to tbl_test_history. This trigger compiles with no errors but when I
    create a record in tbl_test I receive an error. I am not sure if the syntax is correct, can anyone help me with this?

    My bad. I put the colon : into the when clause. They weren't there in your code. Usually I use an if condition, which is a little different.
    I added some NVL logic to to consider comparison of NULL values too.
    CREATE OR REPLACE TRIGGER AU_INSERT_TEST_HISTORY
      AFTER UPDATE  ON TBL_TEST  
      FOR EACH ROW
    BEGIN
      if nvl(:old.ORANGE,'xxx') != nvl(:new.ORANGE,'yyy')
         OR nvl(:old.APPLE,'xxx') != nvl(:new.APPLE,'yyy')
      then
        INSERT INTO TBL_TEST_HISTORY
         (ORANGE, APPLE, BANANA, GRAPE)
        values (:new.ORANGE,
                 :new.APPLE,
                 :new.BANANA,
                 :new.GRAPE);
      end if;
    END AU_INSERT_TEST_HISTORY;
    / You can additionally consider to make this trigger an AFTER INSERT OR UPDATE trigger.
    Then you would also put the inserted values from the start into your history table.
    Edited by: Sven W. on Aug 9, 2012 4:14 PM

  • INSERTING INTO A TABLE FROM ANOTHER TABLE

    Hi,
    I am having a table called emp in which 5 columns are there, I want to insert some rows from another table called employees, only into three columns of emp table through a sub query.
    Is this scenario is possible, I tried so many queries but it is not working out.
    Can any body help me out.
    The columns in emp table is
    empno, ename, doj, designation, salary, deptno, mgrid
    The columns in employees table is
    empno, name, hiredate, post, salary, commission, deptno, mgr
    I want to insert into empno, ename, doj, designation columns of emp table from the employees table empno, name, hiredate, post columns.
    Ramesh.

    It looks like your EMP table has 7 columns, not 5, and you want to insert into 4 columns, not 3.
    insert into emp
      (empno, ename, doj, designation)
      select empno, name, hiredate, post
        from employees;

  • Help! about insert into one table from two tables'data?

    hi,all friends!
    i have a question:
    i have two table as like this:
    table_one(id,ipaddr,col1,col2) primary key(id,ipaddr)
    table_two(id,ipaddr,col1,col3,col4) primary key(id,ipaddr)
    about table_one and table_two,it's columns may change execept id and ipaddr,
    how can i insert the data of table_one and table_two into table_three,the columns of table_three may change with the columns of table_one and table_two
    table_three may dynamic create,but it's primary key is (id,ipaddr)
    thanks!
    pls help!
    any suggestion welcome!

    insert into table_3
    (id, ipaddr, col1, col2, col3, col4)
    select t1.id, t1.ipaddr, t1.col1, t1.col2, t2.col3, t2.col4
    from table_1 t1, table_2 t2
    where t2.id = t1.id
    and t2.ipaddr = t1.ipaddr;

  • How to insert into xml table from relational table

    I wrote a sqlstaement that selects value from the relational tables. Now I want to replace root node "<event_start01>" with following value to the above selected xml string. My select returns root node and all nodes and elements of the root node.
    I tried holding above sellected value into varchar2 variable but I get ora-00600 error. If I hold above selected values into xmltype variable then I am not able to replace root node with the following value.
    I want to rplace rootnode with the following string.
    INSERT INTO FRMD_EVENT_START01(xml_event_start) VALUES
    (XMLTYPE('<event_start01
    xmlns="event_start01.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="event_start01.xsd
    event_start01.xsd">

    Normally, you'd do this by joining B, C, and D together. In the simplest case, something like
    INSERT INTO A( col1, ... col10 )
      SELECT B.col1, ..., B.col4,
             C.col5,
             D.col6, ..., D.col10
        FROM B,
             C,
             D,
       WHERE B.someKeyColumn = C.someKeyColumn
         AND C.anotherKeyColumn = D.anotherKeyColumnYou'd have to know how the data in B, C, and D relate to fill in the WHERE clause. This basically tells Oracle how to match the data in a particular row in B with the data in a particular row in C with the data in a particular row in D.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Inserting into a table which is created "on the fly" from a trigger

    Hello all,
    I am trying to insert into a table from a trigger in Oracle form. The table name however, is inputted by the user in am item form.
    here is what the insert looks like:
    insert into :table_name
    values (:value1, :value2);
    the problem is that forms does not recognize ::table_name. If I replace :table_name with an actual database table, it works fine. However, I need to insert to a table_name based from oracle form item.
    By the way, the table|_name is built on the fly using a procedure before I try to insert into it.
    Any suggestion on how can I do that? My code in the trigger is:
    declare
    dm_drop_tbl(:table_name,'table) // a call to an external procedure to drop the table
    dm_create_tbl(:table_name,'att1','att2');
    insert into :table_name
    values (:value1, :value2);
    this give me an error:
    encounter "" when the symbol expecting one.....

    Hi ,
    You should use the FORMS_DDL built_in procedure. Read the on-line documentation of forms ...
    Simon

  • How can I insert into a table other than the default table in a form

    Hi,
    I want to insert into a table with some fields value of a form of another table. I have written insert code On successful submission of that form, but after submit it gives the following error
    An unexpected error occurred: ORA-06502: PL/SQL: numeric or value error (WWV-16016)
    My code is like this
    declare
    l_trn_id number;
    l_provider_role varchar2(3);
    l_provider_id varchar2(10);
    begin
    l_trn_id := p_session.get_value_as_number(p_block_name=>'DEFAULT',p_attribute_name=>'A_TRANSACTION_ID');
    l_provider_id := p_session.get_value_as_varchar2(p_block_name=>'DEFAULT',p_attribute_name=>'A_PROVIDER1');
    l_PROVIDER_ROLE := p_session.get_value_as_varchar2(p_block_name=>'DEFAULT',p_attribute_name=>'A_PROVIDER_ROLE1');
    if (l_provider_role is not null) and (l_provider_id is not null) then
    insert into service_provider_trans_records(service_provider_id,transaction_id,role_type_id)
    values(l_provider_id, l_trn_id, l_provider_role);
    commit;
    end if;
    end;
    Where 'PROVIDER1' and 'PROVIDER_ROLE1' are not table fields.
    How can do that or why this error comes ? Any idea?
    Thanks
    Sumita

    Hi,
    When do you get this error? Is it while running or while creating the form.
    Here is a sample code which inserts a non-database column dummy into a table called dummy. This is done in successful procedure.
    declare
    l_dummy varchar2(1000);
    begin
    l_dummy := p_session.get_value_as_varchar2(p_block_name=>'DEFAULT',
    p_attribute_name=>'A_DUMMY');
    insert into sjayaram903_1g.dummy values(l_dummy);commit;
    end;
    Please check in your case if the size of the local variable is enough to hold the values being returned.
    Thanks,
    Sharmila

Maybe you are looking for

  • How to create dependent LOV based on procedure?

    Hi, There are two dependent list of values which i need to create. There is an existing package which returns the list. Can you suggest which approach should i use to create these list. Should i execute the procedure in the IMPL class and then bind t

  • Working space settings for Grayscale?

    (Preliminary remark: I'm using the German version of PS, so some items may be called differently in the English version.) In the colour settings of PS CS4 I can define a working space for gray scale pictures. What does this setting actually do? I kno

  • ITunes could not connect - timed out

    For the past year I've had no problems using iTunes and my Ipod. But for the past month I can't connect properly to iTunes. I get a message saying: "iTunes could not connect to the iTunes store. The Network connection timed out. Make sure your networ

  • Workflow Agent  (HR Position) left vacant, no agent determine by workflow

    Hi, We are using PR release workflow WS00000038 and the procesing agent tie to the Release code is Position (created in SAP HR organisition structure). Currently workflow flow to the Personal number/user ID that assigned under the Position, however o

  • Toplink support for Java 5.0

    I tried to import java classes, compiled with jdk 5.0 into Toplink workbench. The mapping fails. I tried to run the workbench with jre 5.0 but that didn't work either. Does anyone know how to do it and does Toplink even have a version that supports j