Insert and update the nested table

Hello

I created a nested table containing the following columns. I need to insert records into the nested table. And also I have to update the nested table. Please find below my table and get error message.

Please advose...!
SQL> create type details as object(
  2  basic number(7,2),
  3  da number(6,2),
  4  hra number(6,2),
  5  pf number(6,2),
  6  it number(6,2),
  7  gross number(7,2),
  8  ded number(6,2),
  9  net number(8,2));
 10  /

Type created.

SQL> create type details_t is table of details;
  2  /

Type created.


SQL> ed
Wrote file afiedt.buf

  1  create table emp_tab(empno number(4),name varchar2(10),details_tab details_t)
  2* nested table details_tab store as empl_details
SQL> /

Table created.


SQL> ed
Wrote file afiedt.buf

  1* insert into emp_tab values(&empno,'&name',details_t(details(&da,&hra,&pf,&it,null,null,null)))
SQL> /
Enter value for empno: 1
Enter value for name: asdf
Enter value for da: 120
Enter value for hra: 130
Enter value for pf: 120
Enter value for it: 120
old   1: insert into emp_tab values(&empno,'&name',details_t(details(&da,&hra,&pf,&it,null,null,null
new   1: insert into emp_tab values(1,'asdf',details_t(details(120,130,120,120,null,null,null)))
insert into emp_tab values(1,'asdf',details_t(details(120,130,120,120,null,null,null)))
                                             *
ERROR at line 1:
ORA-02315: incorrect number of arguments for default constructor
Can I use '&' while inserting records in the nested table? Yes / No?

I do need to update also net gross, ded, columns... !!

Please help me... !!

Concerning
A
$ sqlplus scott/tiger

SQL*Plus: Release 10.2.0.2.0 - Production on Thu Apr 21 16:18:16 2011

Copyright (c) 1982, 2005, Oracle.  All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> CREATE TYPE details AS OBJECT(
 basic NUMBER(7,2),
 da NUMBER(6,2),
 hra NUMBER(6,2),
 pf NUMBER(6,2),
 it NUMBER(6,2),
 gross NUMBER(7,2),
 ded NUMBER(6,2),
 net NUMBER(8,2));  2    3    4    5    6    7    8    9
 10  /

Type created.

SQL> CREATE TYPE details_t IS TABLE OF details;
  2  /

Type created.

SQL> CREATE TABLE emp_tab(empno NUMBER(4),name VARCHAR2(10),details_tab details_t)
 NESTED TABLE details_tab store as empl_details  2
  3  /

Table created.

SQL> INSERT INTO emp_tab VALUES(7001,'Saubhik',details_t(details(100,100,50,10,10,null,null,null)));

1 row created.

SQL> SELECT * FROM TABLE (SELECT details_tab FROM emp_tab WHERE empno=7001);

     BASIC         DA        HRA         PF         IT      GROSS        DED
---------- ---------- ---------- ---------- ---------- ---------- ----------
       NET
----------
       100        100         50         10         10

SQL> ^C

SQL> ed
Wrote file afiedt.buf

  1  UPDATE TABLE (SELECT details_tab FROM emp_tab WHERE empno=7001)
  2     emp_sal
  3*    SET emp_sal.net=emp_sal.basic+emp_sal.da+emp_sal.hra
SQL> /

1 row updated.

SQL> SELECT * FRM emp_tab;
SELECT * FRM emp_tab
         *
ERROR at line 1:
ORA-00923: FROM keyword not found where expected

SQL> SELECT * FROM emp_tab;

     EMPNO NAME
---------- ----------
DETAILS_TAB(BASIC, DA, HRA, PF, IT, GROSS, DED, NET)
--------------------------------------------------------------------------------
      7001 Saubhik
DETAILS_T(DETAILS(100, 100, 50, 10, 10, NULL, NULL, 250))

SQL>

Tags: Database

Similar Questions

  • in bulk accumulate in plsql and update the same table.

    Hello

    I use bulk collect and update the table that I use the slider. This table has nearly 1 million records. There will be problems with my code? Any help is greatly appreciated.

    DECLARE

    terminate_reason VARCHAR2 (1000);

    time_line NUMBER;

    limit_in NUMBER;

    CURSOR cur_violations IS

    SELECT * from abc_table;

    TYPE cur_abc_table_type IS TABLE OF cur_abc_table % ROWTYPE INDEX BY PLS_INTEGER;

    cur_abc_table_rec cur_abc_table_type;

    BEGIN

    limit_in: = 5000;

    OPEN cur_abc_table.

    LOOP

    Get the cur_abc_table COLLECT in BULK

    IN limit_in LIMIT cur_abc_table_rec;

    dbms_output.put_line ('new count is' | cur_abc_table_rec.count);

    WHEN OUTPUT cur_abc_table_rec.count = 0;

    BECAUSE me in 1... cur_abc_table_rec. Count

    LOOP

    time_line: = trunc (sysdate) - cur_abc_table_rec (i) .viol_date;

    IF (time_line > 1000)

    THEN

    terminate_reason: = 'NOTWELL. "

    ON THE OTHER

    terminate_reason: = 'PUSHED ';

    END IF;

    UPDATE abc_table v

    SET

    v.pers_terminate_reason = terminate_reason;

    END LOOP;

    END LOOP;

    COMMIT;

    CLOSE Cur_abc_table;

    EXCEPTION

    WHEN no_data_found THEN

    dbms_output.put_line ('no data is found in the selection' |) SQLERRM);

    WHILE OTHERS THEN

    dbms_output.put_line ('another error' |) SQLERRM);

    END;

    Thank you

    KK

    What happened when you tried? The sliders were ' for the update of "syntax, so there is no general problem update lines inside a loop of cursor.

    The big question you have, it is that the loop is completely and totally useless. What you can do in SQL, do in SQL - not to complicate things with PL/SQL that you don't need.

  • Inserting data in the nested table

    I explore the differences between the OBJECT and RECORD.

    As I'm still learning, I found that both are structures which essentially brings together different elements of types of different data or columns of data types, one is used in SQL and other is used in PL/SQL, please correct me if I'm wrong in my understanding.

    Below, I am trying to insert data into an array of type object, but I can't can you please help.

    CREATE OR REPLACE type sam as OBJECT
    (
    v1 NUMBER,
    v2 VARCHAR2(20 CHAR)
    );
    
    ---Nested Table---
    create or replace type t_sam as table of sam;
    
    --Inserting data----
    insert into table(t_sam) values(sam(10,'Dsouza'));
    

    Error message:

    Error starting at line 22 in command:
    insert into table(t_sam) values(sam(10,'Dsouza'))
    Error at Command Line:22 Column:13
    Error report:
    SQL Error: ORA-00903: invalid table name
    00903. 00000 -  "invalid table name"
    *Cause:    
    *Action:
    

    Ariean wrote:

    So the only purpose of the equivalent concept of SQL types of nested tables is to use one of the data types when you define an actual table?

    So-you can certainly use more that a simple "set an actual table. (I'm fairly certain that you can pass a table nested within a procedure, for example - try it, though - I'm not 100% sure on that - it just 'logic'.) If you can define a type, you can use it, pass it around, whatever.).

    Ariean wrote:

    And this nested table could be a record in SQL or object in PLSQL or simple data type (varchar number, etc.)?

    Nested tables are just like any other type of custom data. You can create a nested table of other types of data. You can create a custom of nested tables data type.

    Stupidly, he could become... uh, stupid O_0

    CREATE TYPE o_myobj1 AS object ( id1   number, cdate1  date );
    
    CREATE TYPE t_mytype1 AS table of o_myobj1;
    
    CREATE TYPE o_myobj2 AS object ( id2   number,  dumb  t_mytype1 );
    
    CREATE TYPE t_dumber AS table of o_myobj2;
    

    O_0

    OK, my brain is starting to hurt - I hope you get the idea

    Ariean wrote:

    Second is my understanding correct any OBJECT & RECORD?

    I see no benefit to describe another way.

  • Insert and update when locking tables

    Update and its grid

    Is it possible for me to insert a record and update of 2 fields in another folder, whil the table locking of data base for the process unfold?

    If so, how?

    Thank you

    Pete

    The LOCKING command works with the client session (MySQL client).

    You can read this link

    http://www.brainbell.com/tutors/PHP/php_mysql/When_and_how_to_lock_tables.html

    Or this link

    http://dev.MySQL.com/doc/refman/5.1/en/lock-tables.html

    Is impossible to change the field of PK and AUTO_INCREMENT? You will need special permits to use LOCK. So, maybe you can change the structure of field too.

  • How to assign values to the nested table and passes as a parameter for the procedure?

    How to assign values to the nested table and passes as a parameter for the procedure?

    Here are the object and its type

    create or replace type test_object1 as an object
    (
    val1 varchar2 (50).
    val2 varchar2 (50).
    VARCHAR2 (50) val3
    );


    create or replace type test_type1 is table of the test_object1;


    create or replace type test_object2 as an object
    (
    val1 varchar2 (50).
    val2 varchar2 (50).
    VARCHAR2 (50) val3
    );


    create or replace type test_type2 is table of the test_object2;


    GRANT ALL ON test_object1 to PUBLIC;


    GRANT ALL ON test_type1 to PUBLIC;


    GRANT ALL ON test_object2 to PUBLIC;


    GRANT ALL ON test_type2 to PUBLIC;

    Here is the table object type:

    create the table test_object_tpe
    (
    sl_num NUMBER,
    Description VARCHAR2 (100),
    main_val1 test_type1,
    main_val2 test_type2
    )


    NESTED TABLE main_val1 STORE AS tot1
    NESTED TABLE main_val2 STORE AS earlier2;


    -----------------------------------------------------------------------------------------------------------

    Here is the procedure that inserts values into the nested table:

    PROCEDURE INSERT_TEST_DATA (sl_num in NUMBER,
    Description in VARCHAR2,
    p_main_val1 IN test_type1,
    p_main_val2 IN test_type2
    )
    IS
    BEGIN

    FOR rec in p_main_val1.first... p_main_val1. Last
    LOOP

    INSERT INTO xxdl.test_object_tpe
    (
    sl_num,
    Description,
    main_val1,
    main_val2
    )
    VALUES
    (
    sl_num
    description
    test_type1 (test_object1)
    p_main_val1 .val1 (CRE),
    p_main_val1 .val2 (CRE),
    p_main_val1 .val3 (rec)
    )
    )
    test_type2 (test_object2 (p_main_val2 .val1 (CRE),
    p_main_val2 .val2 (CRE),
    p_main_val2 .val3 (rec)
    )
    )

    );

    END LOOP;

    commit;

    END INSERT_TEST_DATA;

    -------------------------------------------------------------------------------------------

    Here are the block anonymoys what values attributed to the object type and pass values in the procedure:

    Set serveroutput on;

    declare

    p_sl_num NUMBER: = 1001;
    p_description VARCHAR2 (50): = 'Test Val1;

    inval1 test_type1: = test_type1();
    inval2 test_type2: = test_type2();

    Start


    inval1 (1) .val1: = "testx1";
    inval1 (1) .val2: = "testx2";
    inval1 (1) .val3: = "testx3";

    inval2 (1) .val1: = "testy1";
    inval2 (1) .val2: = "testy2";
    inval2 (1) .val3: = "testy3";

    CSI_PKG. INSERT_TEST_DATA (sl_num = > p_sl_num,)
    Description = > p_description,
    p_main_val1 = > inval1,
    p_main_val2 = > inval2
    );

    end;
    /
    Someone can correct me.

    Thank you
    Lavan

    Thanks for posting the DOF and the sample code but whenever you post provide your Oracle version 4-digit (result of SELECT * FROM V$ VERSION).
    >
    How to assign values to the nested table and passes as a parameter for the procedure?
    >
    Well you do almost everything bad that could be hurt.

    Here is the code that works to insert data into your table (the procedure is not even necessary).

    declare
    p_sl_num NUMBER := 1001;
    p_description VARCHAR2(50) := 'Testing Val1';
    inval1 test_type1 := test_type1();
    inval2 test_type2 := test_type2();
    begin
    inval1.extend();
    inval1(1) := test_object1('testx1', 'testx2', 'testx3');
    inval2.extend();
    inval2(1) := test_object2('testy1', 'testy2', 'testy3');
    
    INSERT INTO test_object_tpe
    (
    sl_num,
    description,
    main_val1,
    main_val2
    )
    VALUES
    (p_sl_num, p_description, inval1, inval2);
    commit;
    end;
    /
    

    See example 5-15 making reference to an element of nested Table Chapter 5 using PL/SQL collections and records in the PL/SQL doc
    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/Collections.htm#CJABEBEA

    1. you don't even have the procedure because it is a simple INSERTION in the table you can do directly (see my above code)

    inval1(1).val1 := 'testx1';
    

    Since you have not yet created all the elements, there is no element 1 "inval1". You need EXTEND the collection to add an element

    inval1.extend();
    

    And then, there is an empty element, but "inval1" is a container for objects of type 'test_object1' not for scalars as "val1", "val2", and "val3".
    If you can not do

    inval1(1).val1 := 'testx1';
    

    You must create an instance of 'test_object1 '.

    inval1(1) := test_object1('testx1', 'testx2', 'testx3');
    

    And so on for the other collection

    You don't need the procedure (as my code example shows), but once you fill in the variables correctly it will work.

  • Only one Integrator for export csv to table and update the table?

    Hello
    I have a requirement where I need to create a single Integrator for export data in the CSV file into a custom oracle table and also use the same Integrator to download and update the custom table data. Is it possible to do this in a single Integrator.

    Thank you
    Kishore

    Yes you can do it.

    You must create a type of UPDATE metadata Integrator.

    First time:

    Custom table is empty.

    WEB ADI will download a blank Excel sheet. Copy the data from the CSV file and paste this Excel.Then download this file that will update the Integrator.

    A sample example is as follows:

    web_adi_pkg.main (param_1, param_2,... param_n)
    download_data;
    upload_data;

    Download data-> select query to download the data (select * from custom_table)
    Download the data-> insert into custom_table where NOT EXISTS (select 1 from custom_table where primary_key = primary_key_col_from_csv)
    update of custom_table where there are (select 1 from custom_table where primary_key = primary_key_col_from_csv)

    Please try above logic.

  • Insert and update by the select statement

    Hi all
    How can I insert and update in an oracle 10g database table
    by a select statement. do not merge.

    Florian wrote:
    Hi all
    How can I insert and update in an oracle 10g database table
    by a select statement. do not merge.
    >

    How can I insert and update in a table of database oracle 10g via a select statement. do not merge.

    Do you mean by using subqueries?

    Something like

    insert into whatever
      ...select statement
    
     update whatever
        set (column, column) = (select column, column ...)
    

    There is a lot of information on this topic in the online documentation

  • apostrophe problem for insert and update pages

    I read in the book "Dreamweaver MX dynamic Applications" that a solution must be placed in the ASP to insert code and form fields record updated to replace the apostrophes by their equivalent html entity character (') before its entry in a database do not have SQL wrong interpret the entered text. How would you say this hotfix is essential because I tested my form with apostrophes and have not gotten into trouble yet?

    > I read in the book "Dreamweaver MX dynamic Applications" as a fix
    > should
    > place in the ASP code for insert and update the fields of the registration form to
    > replace
    > apostrophes with their equivalent html entity character (') before his
    > entry
    > in a database do not have SQL wrong interpret the entered text. How
    > Essentials
    > would you say this fix is that I tested my form with single quotes and
    > have
    > not got any trouble yet?

    If you are user of Jack and sending it to the db in plaintext in
    the query, and then people can use techniques of SQL injection basically destroy
    your database:

    http://en.Wikipedia.org/wiki/SQL_injection

    So, Yes, it's a pretty serious problem.

    -Darrel

  • Create triggers in the table, sequence, insert and update with "model"?

    It must be of rtfm, trial and error thing but you wanted to ask, is it possible to have models or similar automation for the following scenario:

    1.), I add the table to the logic model

    2.) Using glossary I transform a relational model that was recovered / synchronized with the data dictionary

    3.) then I have the new table to add

    -but

    I would then have auto-DDL of to be synchronized to database:

    -create sequence for the id column

    -create table

    -create indexes for the id column pk

    -Create triggers for insert and update

    -l' idea is to have db_created_dt and db_modified_dt defined in the table, so that each table has them to the fields of record etc.

    -activate the triggers

    Each of them following the same naming convention.

    Similarity with approx. generator Apex workshop utils sql create table of the copy paste "excel" that creates 'id' - column + sequence and insert the trigger.

    rgrds Paavo

    Hi Paavo,

    most of the steps can be made in one or other way

    -create sequence for the id column

    -create table

    -create indexes for the id column pk

    If you want to start in the logic model and you don't want to have the ID column in the logic model and select 'Create the surrogate key' checkbox in the dialog entity - you will get an identity column in the relational model and the version of database and settings in ' preferences > Data Modeler > model > physics > Oracle "you can set the sequence generation and the trigger for taking in load.

    fields of record defined in the table, so that each table has them

    You can add the same set of columns in all tables with the transformation script 'model of Table... ».

    You can also look here Oracle SQL Developer Data Modeler 4.1 user - defined DDL generation using transformation scripts

    to see how to grant your DDL generation using the transformation script. DM comes with example to generate separate tables of logging and triggers. You can create your build script of triggers that support logging in these common columns.

    Philippe

  • How to modify and update a line later was inserted and updated in the doDML() method?

    Mr President

    Jdev worm is 12.2.1

    How to modify and update a line later was inserted and updated in the doDML() method?

    I added two rows in my table a method of action-listener in bean managed and secondly with operation doDML() as below.

    Method 1-first row in managed bean

        public void addNewPurchaseVoucher(ActionEvent actionEvent) {
            // Add event code here...
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();        
            DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VoucherView1Iterator");        
            RowSetIterator rsi = dciter.getRowSetIterator();        
            Row lastRow = rsi.last();        
            int lastRowIndex = rsi.getRangeIndexOf(lastRow);        
            Row newRow = rsi.createRow();        
            newRow.setNewRowState(Row.STATUS_NEW);        
            rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow);         
            rsi.setCurrentRow(newRow);
            
            BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry();        
            DCIteratorBinding dciter1 = (DCIteratorBinding) bindings1.get("VdetView1Iterator");        
            RowSetIterator rsi1 = dciter1.getRowSetIterator();        
            Row lastRow1 = rsi1.last();        
            int lastRowIndex1 = rsi1.getRangeIndexOf(lastRow1);        
            Row newRow1 = rsi1.createRow();        
            newRow1.setNewRowState(Row.STATUS_NEW);        
            rsi1.insertRowAtRangeIndex(lastRowIndex1 +1, newRow1);         
            rsi1.setCurrentRow(newRow1); 
            
            
        }
    


    Method of doDML() of line 2 seconds in the entityImpl class


        protected void doDML(int operation, TransactionEvent e) {        
            setAmount(getPurqty().multiply(getUnitpurprice()));
           
            if (operation == DML_INSERT)  
                       {          
                         insertSecondRowInDatabase(getVid(),getLineitem(),getDebitst(),
        (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));  
                           }
                           
                           if(operation == DML_UPDATE)
                           {
                               
                           updateSecondRowInDatabase(getVid(),getLineitem(),getDebitst(),
        (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));                        
                           }                                       
            super.doDML(operation, e);
        }
    
        private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)  
                  {  
                    PreparedStatement stat = null;  
                    try  
                    {  
                      String sql = "Insert into vdet (VID,LINEITEM,DEBITST,AMOUNT) values 
       ('" + value1 + "','" + value2 + "','" + value3 + "','" + value4 + "')";  
                      System.out.println("sql= " + sql);    
                      stat = getDBTransaction().createPreparedStatement(sql, 1);  
                      stat.executeUpdate();  
                    }  
                    catch (Exception e)  
                    {  
                      e.printStackTrace();  
                    }  
                    finally  
                    {  
                      try  
                      {  
                        stat.close();  
                      }  
                      catch (Exception e)  
                      {  
                        e.printStackTrace();  
                      }  
                    }  
                  }  
                  
                  private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)  
                  {  
                    PreparedStatement stat = null;  
                    try  
                    {  
                      String sql = "update vdet set vid='"+ value1+"',lineitem='"+ value2+"',DEBITST='" 
       + value3 + "', AMOUNT='" + value4 + "' where VID='" + VID + "'";  
                      System.out.println("sql= " + sql);      
                      stat = getDBTransaction().createPreparedStatement(sql, 1);  
                      stat.executeUpdate();  
                    }  
                    catch (Exception e)  
                    {  
                      e.printStackTrace();  
                    }  
                    finally  
                    {  
                      try  
                      {  
                        stat.close();  
                      }  
                      catch (Exception e)  
                      {  
                        e.printStackTrace();  
                      }  
                    }  
                  }
    

    Now the problem is that when later I change the quantity and price of the first line isn't updated but second row, because I used the command

     <af:button actionListener="#{bindings.Commit.execute}" text="Commit"
    

    This button update the first line added by bean managed, but the second row remains unchanged.

    Please help how to update the two lines with the same button or something else.

    Concerning

    DML_UPDATE will call only if there is some change data attributes.

    I guess that the update statement is false because vid looks like a primary key for the table, then, how update you the primary key of the update statement and how the update condition statement where the vid = '0'

    I assume the update statement should look like:

      private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)
      {
        PreparedStatement stat = null;
        try
        {
          String sql =
            "update vdet set lineitem='" + value2 + "',DEBITST='" + value3 + "', AMOUNT='" + value4 +
            "' where VID='" + value1 + "'";
          System.out.println("sql= " + sql);
          stat = getDBTransaction().createPreparedStatement(sql, 1);
          stat.executeUpdate();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
            stat.close();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
      }
    
  • How to upgrade the parent table and child by updating the parent table

    I have a parent EMPLOYEE table that includes columns (sysid, serviceno, employeename...) sysid is the primary key, serviceno is the Unique key and I have DEPENDENT child table includes columns (sysid, employee_sysid, name, date of birth...) there still SYSID is a primary key for the table of dependants, employee_sysid is a foreign key in the EMPLOYEE table.

    Now I want to change SYSID (with the help of the sequence) in the EMPLOYEE table that they want an update in the table of people dependent

    Note: I have 10000 records in the EMPLOYEE table as I have 5 more children tables that need to update new SYSID.

    Please help me

    first disable FOREIGN KEY constraints.
    You can update Parent and child record with the help of the trigger.
    Here I give you an examlpe... It can help u.

    create a parent (id number primary key, name varchar2 (100)) table
    /
    create table child_1 (primary key id, p_id number number, date of birth, date)
    CONSTRAINT FK_id FOREIGN KEY (p_id) REFERENCES parent (ID))
    /
    create table child_2 (key primary id, p_id2, addr varchar2 number number (1000))
    CONSTRAINT FK_id2 FOREIGN KEY (p_id2) REFERENCES parent (ID))
    /

    Insert some test data for the parent tables and children.

    change the constraint to disable child_2 table FK_id2
    /
    change the constraint to disable child_1 table FK_id2
    /

    CREATE OR REPLACE TRIGGER delete_child
    BEFORE parent UPDATE ON
    FOR EACH LINE
    BEGIN
    UPDATE CHILD_1
    P_ID =:NEW.ID SET
    WHERE P_ID =:OLD.ID;
    UPDATE CHILD_2
    SET = P_ID2: NEW.ID
    WHERE P_ID2 =:OLD.ID;
    END;
    /

    then Upadte parent table primary key col and check the children tables.
    do enable constraints...

  • Insert and update server behaviors in the same form

    I have a php form that is inserted into a table and then update another table. I have the form of inserting the record first and then I want to update the other table. I'm starting to learn and understand PHP, but I don't know how to have the update function to run after that it inserts the records. I guess that's something like if you insert this disc, then update this record and then go to the redirect page. I know this goes to redirect page after it inserts the record, but I don't know how to tell him not to go to the $insertGoTo. I want him to run the following update function and then go to the $insertGoTo and not the $updateGoTo. Thanks in advance for any help.

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO employee (CompId, empfirstname, empmiddleint, emplastname, EmpType, EmpStatus) VALUES (%s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['CompId'], "int"),
                           GetSQLValueString($_POST['empfirstname'], "text"),
                           GetSQLValueString($_POST['empmiddleint'], "text"),
                           GetSQLValueString($_POST['emplastname'], "text"),
                           GetSQLValueString($_POST['EmpType'], "text"),
                           GetSQLValueString($_POST['EmpStatus'], "text"));
      mysql_select_db($database_dotweb, $dotweb);
      $Result1 = mysql_query($insertSQL, $dotweb) or die(mysql_error());
      $insertGoTo = "Roster.php?CompId=" . $_POST['CompId'] . "";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
      $updateSQL = sprintf("UPDATE company SET CompanyType=%s WHERE CompId=%s",
                           GetSQLValueString($_POST['CompanyType'], "text"),
                           GetSQLValueString($_POST['CompId'], "int"));
      mysql_select_db($database_dotweb, $dotweb);
      $Result1 = mysql_query($updateSQL, $dotweb) or die(mysql_error());
      $updateGoTo = "purchases.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $updateGoTo));
      
    }
    
    

    PHP code is executed from top down and is controlled by the conditional statements ('if' blocks). To achieve what you want, you need to combine the conditional statements that control the insert and update server behaviors and to move the redirect to the end of the code. Amend as follows:

    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      $insertSQL = sprintf("INSERT INTO employee (CompId, empfirstname, empmiddleint, emplastname, EmpType, EmpStatus) VALUES (%s, %s, %s, %s, %s, %s)",
                           GetSQLValueString($_POST['CompId'], "int"),
                           GetSQLValueString($_POST['empfirstname'], "text"),
                           GetSQLValueString($_POST['empmiddleint'], "text"),
                           GetSQLValueString($_POST['emplastname'], "text"),
                           GetSQLValueString($_POST['EmpType'], "text"),
                           GetSQLValueString($_POST['EmpStatus'], "text"));
      mysql_select_db($database_dotweb, $dotweb);
      $Result1 = mysql_query($insertSQL, $dotweb) or die(mysql_error());
    
      $updateSQL = sprintf("UPDATE company SET CompanyType=%s WHERE CompId=%s",
                           GetSQLValueString($_POST['CompanyType'], "text"),
                           GetSQLValueString($_POST['CompId'], "int"));
      mysql_select_db($database_dotweb, $dotweb);
      $Result1 = mysql_query($updateSQL, $dotweb) or die(mysql_error());  
    
      $insertGoTo = "Roster.php?CompId=" . $_POST['CompId'] . "";
    
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: %s", $insertGoTo));
    }
    
  • Columns of the nested Table and ADF BC 11.1.2

    I think coming to a new conception of the application, including a redesign of the database. In this application, there are users who cannot change tables of production directly, but their amendments must be approved (and possibly modified) before applying them to production tables. The production tables are part of an existing system and are fairly well standardized, with a main table and several paintings of detail.

    So for the new design, I want to have a table intermediate, mirrored in the main table, where the user's changes are stored until they are approved and applied to the production tables. The intermediate table contains some additional columns for the user "add, change or delete", who supported the change, the date modified is requested. After you apply the change, the intermediate folder must be copied in a historic change and deleted from the staging table. In this way, the intermediate table is never a lot of data in it.

    Here's the question:
    I need to treat the tables in detail. I could have staged versions of each table in detail, but I thought it might be easier to manage if detail tables have been included in table nested table columns main staging area. Most of the detail tables contain only a few rows with rank of master. But ADF BC 11.1.2 can treat the nested table columns? Is it easy to use in an application?

    Hello

    and ADF Faces does support nested tables? lol so even if ADF BC would be, where would you go with this approach? Polymorphic views would be an option (think hard)?

    Frank

  • Merge into the nested table

    Hi all
    Can I combine the records in the nested table
    I have a table with 2 colum: col_1 and col_2
    col_1: corresponds to the id (varchar2)
    col_2: is a column nested with the type of table (sub_col_1 (number), sub_col_2 (number))

    for example: I have 2 accounts table ('a', (1,2)) and ('b', (3,4)))

    what I want is merged into this table with values ('a', '4.5')) + ('c', (6,7)) IN a single statement

    What I should have after this operation ('a', (1,2,4,5)) + ('b', (3,4)) + ('c', (6,7)).
    Can I do this?
    CREATE OR REPLACE TYPE TEST_TYPE AS OBJECT(SUB_COL_1 NUMBER, SUB_COL_2 NUMBER) ;
    
    CREATE OR REPLACE TYPE TEST_TYPE_TABLE IS TABLE OF TEST_TYPE;
    
    CREATE TABLE TEST_MERGE_NESTED_TABLE (COL_1 VARCHAR2(1 CHAR), COL_2 TEST_TYPE_TABLE)
        NESTED TABLE COL_2 STORE AS COL_2_NESTED;
        
    INSERT INTO TEST_MERGE_NESTED_TABLE VALUES('a',TEST_TYPE_TABLE(TEST_TYPE(1,2) ));
    INSERT INTO TEST_MERGE_NESTED_TABLE VALUES('b',TEST_TYPE_TABLE(TEST_TYPE(3,4) ));
    Oracle version: 11.2.0.3
    Thank you all.

    Published by: 966205 on 20:18 21/02/2013

    Published by: 966205 on 20:42 21/02/2013

    966205 wrote:
    That means he does the same thing as what I want (adding? do not recreate this column in the physical layer).

    Actually, no.
    All content of the nested table is first removed (for the given FK), then the result of the MULTISET UNION is reinserted.

    The evidence on:

    SQL> alter session set events '10046 trace name context forever, level 12';
    
    Session altered.
    
    SQL> merge into test_merge_nested_table t
      2  using (
      3    select 'a' col_1, TEST_TYPE_TABLE(TEST_TYPE(4,5)) col_2 from dual union all
      4    select 'c' , TEST_TYPE_TABLE(TEST_TYPE(6,7))            from dual
      5  ) v
      6  on ( t.col_1 = v.col_1 )
      7  when matched then update
      8    set t.col_2 = t.col_2 multiset union v.col_2
      9  when not matched then insert (col_1, col_2)
     10   values (v.col_1, v.col_2) ;
    
    2 rows merged.
    
    SQL> alter session set events '10046 trace name context off';
    
    Session altered.
    
    SQL> select * from test_merge_nested_table;
    
    C COL_2(SUB_COL_1, SUB_COL_2)
    - --------------------------------------------------------------------------------
    c TEST_TYPE_TABLE(TEST_TYPE(6, 7))
    a TEST_TYPE_TABLE(TEST_TYPE(1, 2), TEST_TYPE(4, 5))
    b TEST_TYPE_TABLE(TEST_TYPE(3, 4))
    

    TKPROF output:

    DELETE, the nested table statement objectives associated with 'a' and deletes the line after line that it contains (1,2).
    The later INSERTION is performed twice (run count = 2) and target the two nested table 'a' by inserting 2 ranks: former one (1,2) + the new one (4.5) and the nested table 'c' by inserting 1 row (6,7).

    SQL ID: 6bjc2z2t53csn Plan Hash: 132214516
    
    DELETE /*+ REF_CASCADE_CURSOR */ FROM "DEV"."COL_2_NESTED"
    WHERE
     "NESTED_TABLE_ID" = :1
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          1          3           1
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        2      0.00       0.00          0          1          3           1
    
    Misses in library cache during parse: 0
    Optimizer mode: CHOOSE
    Parsing user id: SYS   (recursive depth: 1)
    Number of plan statistics captured: 1
    
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
    ---------- ---------- ----------  ---------------------------------------------------
             0          0          0  DELETE  COL_2_NESTED (cr=1 pr=0 pw=0 time=44 us)
             1          1          1   INDEX RANGE SCAN SYS_FK0000023444N00002$ (cr=1 pr=0 pw=0 time=10 us)(object id 23446)
    
    ********************************************************************************
    
     
    
    ********************************************************************************
    
    SQL ID: 0fzd5yk23jyas Plan Hash: 0
    
    INSERT /*+ NO_PARTIAL_COMMIT REF_CASCADE_CURSOR */ INTO "DEV"."COL_2_NESTED"
      ("NESTED_TABLE_ID","SYS_NC_ROWINFO$")
    VALUES
    (:1, :2)
    
    call     count       cpu    elapsed       disk      query    current        rows
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    Parse        2      0.00       0.00          0          0          0           0
    Execute      2      0.00       0.00          0          2         10           3
    Fetch        0      0.00       0.00          0          0          0           0
    ------- ------  -------- ---------- ---------- ---------- ----------  ----------
    total        4      0.00       0.00          0          2         10           3
    
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 50     (recursive depth: 1)
    Number of plan statistics captured: 1
    
    Rows (1st) Rows (avg) Rows (max)  Row Source Operation
    ---------- ---------- ----------  ---------------------------------------------------
             0          0          0  LOAD TABLE CONVENTIONAL  (cr=1 pr=0 pw=0 time=113 us)
    
    ********************************************************************************
    
  • Trigger on the nested table - possible without sight?

    I have a table my_table that has a nested table column, DOC. I need a trigger that fires whenever a row in the nested table is deleted.

    I had initially hoped that a status UPDATE on my_table trigger would do the trick, but it doesn't. Then I created a trigger on the nested table.

    I can make it work if I create a table view and then make the trigger through this:

    "INSTEAD OF DELETE
    ON the TABLE IMBRIQUEE my_view DOC
    '

    and then to do the removal through the view:

    deletion OF TABLE
    (Doc SELECT FROM my_view where rowid = 1111);

    HOWEVER, I need this to work when the delete statement is directly through the table itself and not through the view. The delete statement is generated by an application that I can't control. I can only make changes to the database.

    deletion OF TABLE
    (Doc SELECT FROM my_table where rowid = 1111);

    Create the trigger on the nested table.

    create or replace type result_obj as object(subject varchar2(100), mark integer)
    /
    create or replace type result_tbl as table of result_obj
    /
    create table student(sno integer, sname varchar2(100), result result_tbl) nested table result store as result_tbl_tbl
    /
    insert into student values(10, 'Karthick', result_tbl(result_obj('English',85),result_obj('Hindi',70)))
    /
    insert into student values(20, 'Vimal', result_tbl(result_obj('English',75),result_obj('Hindi',90)))
    /
    select s.sno, s.sname,r.subject, r.mark
      from student s,
           table(s.result) r
    /
    create or replace trigger Result_Trigger before delete on result_tbl_tbl for each row
    begin
        raise_application_error(-20001,'You cannot delete this subject');
    end;
    /
    delete
      from
     table(select s.result
             from student s
            where s.sno = 10)
     where subject = 'Hindi'
    /
    

Maybe you are looking for