Insert into multiple tables using a page variable

Hi Guys,
I was going to trawl the PL/SQL forum for this but as I need to use a page variable I thought I would try here first.
I have 4 tables 2 live and 2 archive, company_table, company_table_arch, product, product_arch the tables are set up with a company Id as the join.
you can have multiple products to a company.
what I want to do is have an archive button on a form that will select the current record on the company table, and insert it into archive then select all records with that id in the product table and insert them into the product_arch table.
I was thinking about doing this as a couple of page proccess, sound about right?
the other option was using a package,
is it possible to use page variables in a package? If so what is the sintax
cheers
Bjorn

OK, I have got the basis of this working I press the archive button and the records update as per the code.
I have one problem however.
The button is on a form. and if the user updates the form then presses the archive button it copies the data before the table is updated (the table is updated using a save button).
One way round this would be to jump to an "are you sure?" page
Does anyone know a better way of doing this?
cheers
Bjorn

Similar Messages

  • Insert into multiple table view

    I have a view with multiple table query and and INSTEAD OF trigger on the view that inserts into multiple tables. When I attempt to do a commit out of a ADF Creation Form, I get the following error: ORA-01779: cannot modify a column which maps to a non key-preserved table ORA-06512: at line 1.
    Has anyone had success inserting into multiple tables via a view that has more than one table?
    Thanks,
    Lisa

    Lisa,
    Sounds like your instead-of trigger may not be being called and you are trying to insert directly into the view.
    I did write a [url http://stegemanoracle.wordpress.com/2006/03/15/using-updatable-views-with-adf/]blog entry about using a view with instead-of triggers last year.
    John

  • BizTalk 2013 R2 - Oracle client (Insert into Multiple tables) CompositE Transaction

    I know there is Composite Transaction of  inserting into multiple tables in SQL.
    Is there a way where we can have inserts into multiple table at once ? If yes, can anyone please provide step by step procedure to achieve this  
    MBH

    Here is a link on using Oracle DB w/ composite operations: 
    Performing Composite Operations on Oracle Database by Using BizTalk Server
    Rachit
    Please mark as answer or vote as helpful if my reply does

  • Can select, but cannot insert into oracle tables using php.

    I am having trouble inserting data into a tables in oracle using PHP. I can insert into the tables using baninst1, but nothing else. I can't even insert using the tables' owner. Every time I try I get the ORA-00492 error of table or view does not exist. However, I can run a select statement just fine. So far, baninst1 is the only user that can actually do inserts. I've triple checked all the table grants and everything is fine. Also, I can copy/paste the exact insert statement into SQL*Plus and it works with the correct user. It doesn't have to be baninst1. I've tried everything I can think of. I've tried putting the table name in quotes, adding the schema name to the table, checking public synonyms, but everything appears to be ok. I would greatly appreciate any suggestions others may have.
    I'm using PHP 5.2.3 with an oracle 9i DB.

    Here is the code that doesn't work. It works only with baninst1, no other username will work and all I do is change the my_username/my_password to something different. This is one example function where I try to do an insert, but it doesn't work on any of the tables I try.
    Thanks for looking.
    class Oracle {
         private $oracleUser = "my_username";
         private $oraclePassword = "my_password";
         private $oracleDB = "MY_DB";
         private $c = null;
         function Connect() {
              if ( !($this->c = ocilogon( $this->oracleUser, $this->oraclePassword, $this->oracleDB ) ) )
                   return false;
              return true;
         function AddNewTest($testName, $course, $section, $term, $maxAttempts, $length, $startDate, $startTime, $endDate, $endTime)
              $result = "";
              if( $this->c == null )
                   $this->Connect();     
              $splitIndex = strpos($course, " ");
              $subjectCode = substr($course, 0, $splitIndex);
              $courseNumber = substr($course, $splitIndex + 1);
              $insertStatment = "insert into szbtestinfo(szbtestinfo_test_name,
                                                                szbtestinfo_course_numb,
                                                           szbtestinfo_section,
                                                                szbtestinfo_max_attempts,
                                                                szbtestinfo_length_minutes,
                                                                szbtestinfo_start,
                                                                szbtestinfo_end,
                                                                szbtestinfo_id,
                                                                szbtestinfo_subj_code,
                                                                szbtestinfo_eff_term)
                                                                values( '" . $testName .
                   "', '" . $courseNumber .
                   "', '" . $section .
                   "', " . $maxAttempts .
                   ", " . $length .
                   ", to_date('" . $startDate . " " . $startTime . "', 'MM/DD/YYYY HH24:MI')" .
                   ", to_date('" . $endDate . " " . $endTime . "', 'MM/DD/YYYY HH24:MI')" .
                   ", szsnexttest.nextval" .
                   ", '" . $subjectCode .
                   "', '" . $term . "')";
              //return $insertStatment;
              $s = OCIParse($this->c, $insertStatment);
              try
                   $result = OCIExecute($s);
              catch(exception $e)
              return $result;
         }

  • Inserting into multiple tables on one form using UIX

    We are developing an application using struts and UIX. We would like to be able to insert into three tables on one form(view). How can we accomplish this?

    This is more of an ADF question, you'll need to set up view object, than just drag it from the data control palette like normal.
    If it's not already set up as a view in the db (split into multiple tables), you'll need to create a view object that includes all the fields you want, based on multiple entity objects.

  • How to insert into two tables using a Single ADF creation form?

    Hi,
    I need to make a ADF Creation Form that will insert the data at same time in two tables... Like i have two tables Track (Track_id,Track_Name)
    and Module ( Module_id, Track_id, Module_name, Module_Short_name) and i have to insert the data in both the tables using Same Creation Form.
    can anybody help me out and gave me the solution,how to do that?
    Thanks

    if you want to insert different data into two different tables then you can drag the two data objects into creation form..
    If you want to duplicate the data inserted in the one table to another then you can follow two approach
    1. Drag and drop one table, When Save button is invoked then insert data into another table using callable statement.
    or
    2. Create on-insert trigger in Table1 where you can insert data into table2.
    --Prasanna                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • HOW TO READ DATA FROM A FILE AND INSERT INTO A TABLE USING UTL_FILE

    Hi..
    I have a file.I want to read the data from file and load it into a table using utl_file.
    how can I do it?
    Any reply apreciated...

    Hi,
    This is not your requirment but u can try this :
    CREATE OR REPLACE DIRECTORY text_file AS 'D:\TEXT_FILE\';
    GRANT READ ON DIRECTORY text_file TO fah;
    GRANT WRITE ON DIRECTORY text_file TO fah;
    DROP TABLE load_a;
    CREATE TABLE load_a
    (a1 varchar2(20),
    a2 varchar2(200))
    ORGANIZATION EXTERNAL
    (TYPE ORACLE_LOADER
    DEFAULT DIRECTORY text_file
    ACCESS PARAMETERS
    (FIELDS TERMINATED BY ','
    LOCATION ('data.txt')
    select * from load_a;
    CREATE TABLE A AS select * from load_a;
    SELECT * FROM A
    Regards
    Faheem Latif

  • Stored procedure to insert into multiple tables in sql server 2012, using id col from one table to insert into the other 2

    Hi all,
    Apologies if any of the following sounds at all silly but I am fairly new to this so here goes...
    I have 3 tables that require data insertion at the same time. The first table is the customers table, I then want to take the automatically generated custid from that table and inser it into 2 other tables along with some other data
    Here's what I have so far which does not work:
    CREATE PROCEDURE CustomerDetails.bnc_insNewRegistration @CustId int,
    @CompanyName varchar(100),
    @FirstName varchar(50),
    @LastName varchar(50),
    @Email nvarchar(254),
    @HouseStreet varchar(100),
    @Town smallint,
    @County tinyint,
    @Postcode char(8),
    @Password nvarchar(20)
    AS
    BEGIN
    begin tran
    insert into CustomerDetails.Customers
    (CompanyName, FirstName, LastName, EmailAddress)
    Values (@CompanyName, @FirstName, @LastName, @Email)
    set @CustId = (select CustId from inserted)
    insert into CustomerDetails.Address
    (CustomerId, HouseNoAndStreet, Town, County, PostCode)
    values (@CustId, @HouseStreet, @Town, @County, @Postcode)
    insert into CustomerDetails.MembershipDetails
    (CustomerId, UserName, Password)
    values (@CustId, @Email, @Password)
    commit tran
    END
    GO
    If anyone could help with this I would very much appreciate it as I am currently building an online store, if there's no registration there's no customers.
    So to whom ever is able to help, I thank you whole heartedly :)

    I hope by now it is apparent that statements like "doesn't work" are not particularly helpful. The prior posts have already identified your first problem.  But there are others.  First, you have declared @CustID as an argument for your
    procedure - but it is obvious that you do not expect a useful value to be supplied when the procedure is executed.  Perhaps it should be declared as an output argument so that the caller of the procedure can know the PK value of the newly inserted customer
    - otherwise, replace it with a local variable since it serves no purpose as an input argument.
    Next, you are storing email twice.  Duplication of data contradicts relational theory and will only cause future problems. 
    Next, I get the sense that your "customer" can be a person or a company.  You may find that using the same table for both is not the best approach.  I hope you have constraints to prevent a company from having a first and last name (and
    vice versa).
    Next, your error checking is inadequate.  We can only hope that you have the appropriate constraints to prevent duplicates.  You should expect failures to occur, from basic data errors (duplicates, null values, inconsistent values) to system issues
    (out of space).  I'll leave you with Erland's discussion for more detail:
    erland - error handling.
    Lastly, you should reconsider the datatypes you are using for the various bits of information.  Presumably town and county are foreign keys to related tables, which is why they are numeric.  Be careful you don't paint yourself into a corner with
    such small datatypes.  One can also debate the wisdom of using a separate tables for Town and County (and perhaps the decision to limit yourself to a particular geographic area with a particular civic hierarchy). Password seems a little short to me. 
    And if you are going to use nvarchar for some strings, you might as well use it for everything - especially names.  Also, everyone should be security conscious by now - passwords should be encrypted at the very least.
    And one last comment - you really should allow 2 address lines. Yes, two separate ones and not just one much larger one.

  • How do you insert new records into multiple tables using the same unique primary key?

    I’ve created a PHP site and MySQL server using a free app called XAMPP.  I have successfully created a form in Dreamweaver that will write data to a (name) table in the SQL database.  Here’s my question: How do you write to two (or more) tables in the same database and pass the same primary key to both tables?  In the SQL database, I defined the first field as ID and set it as the primary key with auto update.  So, when you insert a new record, it creates a unique primary key for that record.  In my form, I’m capturing info that needs to be stored to two tables at the same time; a Name table and Address table. Since the Name and Address tables use the ID field as the primary key, I believe I will need to pass the ID value from the Name table to the insert of the Address table to insure they both have the same primary key, right?

    No. You probably need the primary key from one table to be a foreign key in the other tables. In any case, I believe you can use two methods to obtain the auto generated key. First with SQL:
    http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html
    And the other using a PHP function:
    http://us3.php.net/mysql_insert_id

  • Insert into multiple tables; grab id from first

    I apologize if this has been answered elsewhere, but I tried
    searching and got no results.
    I'm trying to insert the contents of one form into two
    tables. After inserting some fields into one table, I want to grab
    the key/id from the first table into the second table with the
    other fields.
    I've tried a few different things, including trying to use
    SCOPE_IDENTITY(), but just kept getting lots of errors.
    The current version of my code works perfectly, *except for
    the fact that it doesn't insert the ID*!
    Can anyone tell me what I'm doing wrong? or offer another way
    of doing this?
    Thanks for your help, as usual.

    MarianneStone wrote:
    > The current version of my code works perfectly, *except
    for the fact that it doesn't insert > the ID*!
    > Can anyone tell me what I'm doing wrong?
    The EmployeeID is not inserted because the getMyID query
    cannot find the newly inserted record. When using a UUID to
    identify the new records ..
    <cfquery name="qAddDeptHead" datasource="#db#"
    result="result">
    INSERT INTO Employee(... , EmpUUID)
    VALUES ( ... , '#CreateUUID()#')
    </cfquery>
    You have to use that _same_ UUID to find the record, _not_
    create a new one.
    <cfquery name="getMyID" datasource="#db#">
    SELECT EmployeeID, EmpUUID
    FROM Employee
    WHERE Employee.EmpUUID='#UseTheSameUUIDFromTheFirstQuery#'
    </cfquery>
    As an aside, you could probably do this in two queries not
    three. Just drop the second SELECT query and use an INSERT
    INTO/SELECT .. FROM Table statement instead. Plus you should also
    consider using cfqueryparam for your query parameters. It has many
    benefits.
    http://livedocs.adobe.com/coldfusion/8/htmldocs/Tags_p-q_18.html#1102474
    > Can anyone ... offer another way of doing this?
    There are a few options. For ColdFusion 8, you could use the
    result attribute. After running the INSERT you can grab the new
    EmployeeID by using #yourResult.IDENTITYCOL#
    <cfquery name="qAddDeptHead" datasource="#db#"
    result="yourResult">
    INSERT INTO Employee ( Columns here )
    VALUES (... values here ...)
    </cfquery>
    For earlier versions, you can either use SCOPE_IDENTITY() or
    a UUID value - as you are currently doing now.
    > I've tried a few different things, including trying to
    use SCOPE_IDENTITY(),
    > but just kept getting lots of errors.
    If you use SCOPE_IDENTITY() turn off the rowcount, or the
    query variable "qAddDeptHead" may be undefined when you try and use
    it.
    <cfquery name="qAddDeptHead" datasource="#db#"
    result="yourResult">
    SET NOCOUNT ON;
    INSERT INTO Employee ( Columns here )
    VALUES (... values here ...)
    SELECT EmployeeID AS NewEmployeeID
    SET NOCOUNT OFF;
    </cfquery>
    <cfquery name="qNewEmpPosition" datasource="#db#">
    INSERT INTO EmployeePositions(EmployeeID, .... )
    VALUES ( #qAddDeptHead.NewEmployeeID#, ....)
    </cfquery>

  • Loading data into multiple tables using sqlloader

    Hi,
    I am using sql loader to load the data from flat file into the data base
    my file structure is as below
    ====================
    101,john,mobile@@fax@@home@@office@@email,1234@@3425@@1232@@2345@@[email protected],1234.40
    102,smith,mobile@@fax@@home,1234@@345@@234,123.40
    103,adams,fax@@mobile@@office@@others,1234@@1233@@1234@@3456,2345.40
    in file first columns are empno,ename,comm_mode(multiple values terminated by '@@'),comm_no_txt(multiple values terminated by '@@'), sal
    the comm_mode and comm_no_text needs to be inserted into the separate table (emp_comm) like below
    emp
    empno ename sal
    101 john 1234.40
    102 smith 123.40
    103 adams 2345.40
    emp_comm
    empno comm_mode comm_no_text
    101 mobile 1234
    101 fax 3425
    101 home 1232
    101 office 2345
    101 email [email protected]
    102 mobile 1234
    102 fax 345
    102 home 234
    103 fax 1234
    like this needs to insert the data using sql loader
    my table structures
    ===============
    emp
    empno number(5)
    ename varchar2(15)
    sal number(10,2)
    emp_comm
    empno number(5) reference the empno of the emp table
    comm_mode varchar2(10)
    Comm_no_text varchar2(35)
    now i want insert the file data into the specified structues
    please help me out to achieve this using sql loader
    (we are not using external tables for this)
    Thanks & Regards.
    Bala Sake
    Edited by: 954925 on Aug 25, 2012 12:24 AM

    Pl post OS and database details
    You will need to split up the datafile in order to load into separate tables. The process is documented
    http://docs.oracle.com/cd/E11882_01/server.112/e22490/ldr_control_file.htm#autoId72
    HTH
    Srini

  • Insert into a table using UNIX

    i have file Summary.txt
    contants looks like this
    ./log_CS-185.lst:Error detected, rollbacking
    ./log_CS-13603.lst:Error detected, rollbacking
    ./log_CS-1002.lst:Error detected, rollbacking
    now i have to parse this file to get (CS-185,CS-13603,CS-1002)
    and insert these vlaues into a table... how do i do this using unix script ?..

    i have to parse this file to get (CS-185,CS-13603,CS-1002)
    and insert these vlaues into a table... how do i do this using unix script ?..Example :$ cat read_Sum.sh
    cat Summary.txt | while read LINE
    do
            VAR=`echo $LINE | awk -F_ '{print $2}' | awk -F. '{print $1}'`
            echo $VAR
            sqlplus -s test/test << EOF
            insert into summary values('$VAR');
            exit
    EOF
    done
    $ ./read_Sum.sh
    CS-185
    1 row created.
    CS-13603
    1 row created.
    CS-1002
    1 row created.
    $ sqlplus test/test
    SQL*Plus: Release 10.2.0.3.0 - Production on Thu May 19 13:32:40 2011
    Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> select * from summary;
    CODE
    CS-185
    CS-13603
    CS-1002
    SQL>

  • How to insert into a table using a procedure in a trigger

    I have following trigger and based on the some condition, it should inser a row in to a table using the procedure:
    CREATE OR REPLACE TRIGGER RSSC.RR_SERV_ADD_ON_REQ_bu before update on RSSC.RR_SERV_ADD_ON_REQ
    for each row
    DECLARE
    lr_appr_trans_hdr APPR_TRANS_HDR%ROWTYPE;
    -- Inserting a row into APPR_TRANS_HDR table
              lr_appr_trans_hdr.apth_ref_system := 'RSAO';
              lr_appr_trans_hdr.apth_xref_col_name := 'RSAO_ADD_ON_REQ_NUM';
              lr_appr_trans_hdr.apth_xref_id := :NEW.RSAO_ADD_ON_REQ_NUM;
              lr_appr_trans_hdr.apth_trans_srce := 'I';
              lr_appr_trans_hdr.apth_balance_amt := :NEW.RSAO_TOT_AMT;
              lr_appr_trans_hdr.apth_is_finance_adj := 'N';
              SPI_APPR_TRANS_HDR (
              lr_appr_trans_hdr.apth_id
              ,lr_appr_trans_hdr.apth_create_dt
                   ,lr_appr_trans_hdr.apth_create_user_id
                   ,lr_appr_trans_hdr.apth_update_dt
                   ,lr_appr_trans_hdr.apth_update_user_id
              ,lr_appr_trans_hdr.apth_ref_system
                   ,lr_appr_trans_hdr.apth_xref_col_name
                   ,lr_appr_trans_hdr.apth_xref_id
                   ,lr_appr_trans_hdr.apth_trans_srce
                   ,lr_appr_trans_hdr.apth_udc_name_cd
                   ,lr_appr_trans_hdr.apth_udc_acct_num
                   ,lr_appr_trans_hdr.apth_level1_apprvl_stat
                   ,lr_appr_trans_hdr.apth_level1_apprvl_dt
                   ,lr_appr_trans_hdr.apth_level1_apprvr_id
                   ,lr_appr_trans_hdr.apth_level2_apprvl_stat
                   ,lr_appr_trans_hdr.apth_level2_apprvl_dt
                   ,lr_appr_trans_hdr.apth_level2_apprvr_id
                   ,lr_appr_trans_hdr.apth_received_dt
                   ,lr_appr_trans_hdr.apth_balance_amt
                   ,lr_appr_trans_hdr.apth_cust_name
                   ,lr_appr_trans_hdr.apth_sent_dt
                   ,lr_appr_trans_hdr.apth_wbs_element
                   ,lr_appr_trans_hdr.apth_gl_acct_num
                   ,lr_appr_trans_hdr.apth_is_finance_adj );
    When I use the above, it is saying wrong number of argument or type.
    When I use the following instead, I am getting :NEW.APTH_ID must be declared.
    SPI_APPR_TRANS_HDR('APPR_TRANS_HDR',to_char(:NEW.APTH_ID),'APTH_ID',:OLD.APTH_ID,:NEW.APTH_ID);
    How can use the procedure in a trigger.
    Following is the table structure:
    Column Name     Data Type     Column Comments
    APTH_ID     NUMBER(16) Computed unique identified per large table standards (yyyymmddnnnnnnnn)
    APTH_CREATE_DT     DATE     sysdate
    APTH_CREATE_USER_ID VARCHAR2(65)     ‘conv’
    APTH_UPDATE_DT     DATE     sysdate
    APTH_UPDATE_USER_ID     VARCHAR2(65)     ‘conv’
    APTH_REF_SYSTEM     VARCHAR2(4)     ‘RSAO’
    CPA_PREM_NUM     NUMBER(13,0)     NULL
    RSR_REQ_NUM     NUMBER(16)     NULL
    RSAO_ADD_ON_REQ_NUM     NUMBER(16)     rsao_add_on_req_num
    APTH_TRANS_SRCE     VARCHAR2(2)     ‘I’
    APTH_LDC_NAME_CD     VARCHAR2(4)     NULL
    APTH_LDC_ACCT_NUM     VARCHAR2(25)     NULL
    APTH_LEVEL1_APPROVAL_STAT     VARCHAR2(1)     NULL
    APTH_LEVEL1_APPROVAL_DT     DATE     NULL.
    APTH_LEVEL1_APPROVAL_ID     VARCHAR2(30)     NULL
    APTH_LEVEL2_APPROVAL_STAT     VARCHAR2(1)     NULL
    APTH_LEVEL2_APPROVAL_DT     DATE     NULL.
    APTH_LEVEL2_APPROVAL_ID     VARCHAR2(30)     NULL
    APTH_RECEIVED_DT     DATE     NULL
    APTH_BALANCE_AMT     NUMBER(11,2) RR_SERV_ADD_ON_REQ.rsao_tot_amt – amount previously extracted to sap
    APTH_CUST_NAME     VARCHAR2(65)     NULL
    APTH_SENT_DT     DATE     NULL
    APTH_WBS_ELEMENT     VARCHAR2(25)     NULL
    APTH_GL_ACCT_NUM     VARCHAR2(15) NULL
    APTH_IS_FINANC_ADJ     VARCHAR2(1)     ‘N’
    Edited by: user652807 on Sep 3, 2008 4:51 PM

    It appears you're missing the format mask in the TO_CHAR, ...
    TO_CHAR(:new.apth,'YYYYMMHR24MISS')
    The full code would help a bit more.

  • Select statement to insert into a table using a loop

    hi
    create table uploadtab(
    itema varchar2(3),
    xtype varchar2(1),
    salesa number,
    margina number,
    salesb number,
    marginb number,
    salesc number,
    marginc number);
    insert into uploadtab
      (itema, xtype, salesa, margina, salesb, marginb, salesc, marginc)
    values
      ('abc', 'a', 100, .40, 300, .10, 450, .25);
    create table testinsert(itema varchar2(3),
    xtype varchar2(1),
    sales number,
    margin number);what i want to do is create 3 records based on that one in a loop
    so my desired output for testinsert is as follows
    abc  a 100  .40
    abc  a 300  .10
    abc  a 450  .25i don't want to use 3 insert tables if at all possible
    any help would be greatly appreciated
    thanks in advance
    Edited by: DM on Jul 7, 2010 2:22 PM

    Just a question on this
    INSERT INTO testinsert
    ( itema
    , xtype
    , sales
    , margin
    SELECT  itema
    ,       xtype
    ,       DECODE
            ( RN
            , 1,salesa
            , 2,salesb
            , 3,salesc
    ,       DECODE
            ( RN
            , 1,margina
            , 2,marginb
            , 3,marginc
    FROM            uploadtab
    CROSS JOIN      (
                            SELECT ROWNUM RN
                            FROM   dual
                            CONNECT BY LEVEL <= 3
    ;when you put a WHERE before the CROSS JOIN, the error
    ORA-00933:SQL command not properly ended. is displayed.

  • Insert into another table using record

    Hi all, i am reading from TableA , need to sort the records and insert the sorted order in table B, and need some help with the coding, would appreciate if anyone can help.
    I am using records
    create or replace procedure ZZ AS
    DECLARE
    CURSOR GEN_CUR IS
         select *
         FROM TABLE_A;
            ORDER BY field_1 ASC;
         info_rec GEN_CUR%ROWTYPE;
         BEGIN
              open GEN_CUR;
              LOOP
                   FETCH gen_cur INTO info_rec;
                   EXIT WHEN gen_cur%NOTFOUND;
                   -- i need to insert the record into table_B. table_B's fields are identical to table_A, but am unsure of the code.
              END LOOP;
              CLOSE gen_cur;
         END;Message was edited by:
    learningoracle

    From Oracle 9.2 onwards we can do clever things with records:
    SQL> select * from tab1
      2  /
    K F
    Z X
    A X
    SQL> declare
      2     r tab1%ROWTYPE;
      3  begin
      4     for r in ( select * from tab1 order by key ) loop
      5       insert into tab12 values r;
      6     end loop;
      7  end;
      8  /
    PL/SQL procedure successfully completed.
    SQL> select * from tab12
      2  /
    K F
    A X
    Z X
    SQL> But as K Richards has pointed out you can do this with a straight INSERT ... SELECT statement...
    SQL> roll
    Rollback complete.
    SQL> insert into tab12
      2  select * from tab1 order by key
      3  /
    2 rows created.
    SQL> select * from tab12
      2  /
    K F
    A X
    Z X
    SQL> Note that sort order is only guaranteed when we use an ORDER BY clause.
    Cheers, APC

Maybe you are looking for

  • Data Execution Prevention has closed Adobe Reader

    I cannot launch Adobe Reader, got the following message When I close program, a message says "Data Execution Prevention has closed Adobe Reader."  I have searched the Microsoft Community for fixes, but those suggestions don't work. I'm running Window

  • Forms in numbers...how/ when

    Hi, we would like to enter data via a form in Numbers, but there isn't that funtion available...should I revert to Excel? LIkewise, printing our rows of data in form style, is this possible? Many thanks. E

  • Touch Screen Calibration

    My touch screen is acting like it needs to be recalibrated. Sometimes I touch the screen and something an inch away activates.  When I try to  type in my password random letters fill  - ones I don't hit. Sometimes it ignores my touch completely.  I t

  • HT201272 Is like to obtain all my ringtones from itunes

    I just got off the phone with a apple rep he had very little knowledge on helping me. When I contested he hung up it was rude and unprofessional. I waited two days for this call to not even be helped. I'd like someone to assist me or if you can send

  • How to break down long lines of code

    Is there a way to break a long line of code so that it will fit on an A4 sheet?