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.

Similar Messages

  • 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 insert into a table with a nested table which refer to another table

    Hello everybody,
    As the title of this thread might not be very understandable, I'm going to explain it :
    In a context of a library, I have an object table about Book, and an object table about Subscriber.
    In the table Subscriber, I have a nested table modeling the Loan made by the subscriber.
    And finally, this nested table refers to the Book table.
    Here the code concerning the creation of theses tables :
    Book :
    create or replace type TBook as object
    number int,
    title varchar2(50)
    Loan :
    create or replace type TLoan as object
    book ref TBook,
    loaning_date date
    create or replace type NTLoan as table of TLoan;
    Subscriber :
    create or replace type TSubscriber as object
    sub_id int,
    name varchar2(25)
    loans NTLoan
    Now, my problem is how to insert into a table of TSubscriber... I tried this query, without any success...
    insert into OSubscriber values
    *(1, 'LEVEQUE', NTLoan(*
    select TLoan(ref(b), '10/03/85') from OBook b where b.number = 1)
    Of course, there is an occurrence of book in the table OBook with the number attribute 1.
    Oracle returned me this error :
    SQL error : ORA-00936: missing expression
    00936. 00000 - "missing expression"
    Thank you for your help

    1) NUMBER is a reserved word - you can't use it as identifier:
    SQL> create or replace type TBook as object
      2  (
      3  number int,
      4  title varchar2(50)
      5  );
      6  /
    Warning: Type created with compilation errors.
    SQL> show err
    Errors for TYPE TBOOK:
    LINE/COL ERROR
    0/0      PL/SQL: Compilation unit analysis terminated
    3/1      PLS-00330: invalid use of type name or subtype name2) Subquery must be enclosed in parenthesis:
    SQL> create table OSubscriber of TSubscriber
      2  nested table loans store as loans
      3  /
    Table created.
    SQL> create table OBook of TBook
      2  /
    Table created.
    SQL> insert
      2    into OBook
      3    values(
      4           1,
      5           'No Title'
      6          )
      7  /
    1 row created.
    SQL> commit
      2  /
    Commit complete.
    SQL> insert into OSubscriber
      2    values(
      3           1,
      4           'LEVEQUE',
      5           NTLoan(
      6                  (select TLoan(ref(b),DATE '1985-10-03') from OBook b where b.num = 1)
      7                 )
      8          )
      9  /
    1 row created.
    SQL> select  *
      2    from  OSubscriber
      3  /
        SUB_ID NAME
    LOANS(BOOK, LOANING_DATE)
             1 LEVEQUE
    NTLOAN(TLOAN(000022020863025C8D48614D708DB5CD98524013DC88599E34C3D34E9B9DBA1418E49F1EB2, '03-OCT-85'))
    SQL> SY.

  • How to insert into a table in database1 from a table in database2?

    hi!
    how to insert into a table in database1 from a table in
    database2?
    can anyone help?
    Tariq.

    using the EXEC_SQL package.
    see form help for detail.
    Regards.

  • 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;
         }

  • 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

  • Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
    If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
    If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
    Justin

  • Help Required :Excel Upload Into Oracle Table Using PLSQL Procedure/Package

    Please Help , Urgent Help Needed.
    Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
    Case's are :
    1. Excel File is On Users/ Client PC.
    2. Application is on Remote Server(Oracle Forms D2k).
    3. User Is Using Application Using Terminal Server LogIn.
    4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
    5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
    6. we are Using Oracle 8.7
    So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
    Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
    Jus help to Sort This Issue ........
    you can also write me on :
    [email protected], [email protected]

    I also Tried to Use This
    But How can i Use SQLLDR Command In Stored Procedure.
    Well IN SQL*PlUS it is successfull but in Stored Procedure /Package ,PL/SQL does not recognise the OS commands.
    So now my Question How can I recognise the SQLLDR Commnad in Stored Procedure.

  • 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

  • How to insert record in table using ADF Table

    Hi,
    I am developing and application in ADF .it consist 5 tables.i need to insert into 1 table that contains IDs that are reffered from other tables and on ADF Table fi i dont want to show those IDs. Can somebody provide me solution how to do that?
    like i have a SkillTable - that contains attributes Resource No(number) ,module Id(number), Track id(number), skill_type(number), skill_rating(number), experience(number).
    Track id is reffered from track table
    Module id is reffered from module table
    Resource table is reffered from resource table
    skill_type and skill_rating from lookup table
    and i need to insert into SkillTable using ADF Table. we dont want to show Track id,module id,codes for skill_type nad skill_rating on ADF Table instead we want to show trackname and module name ,code values for skill_type and Skill_rating .
    when we create ADF table for this skill table it shows me ids but what i want is that in each row it should show resource name,modulename,track name,and for skill_type and skill_rating it should show name of skill_types and Skill_rating rather than codes for each skill_type and Skill_rating.
    we tried to insert by creating view ,but didnot work.
    plz provide any solution.
    Thnakls

    Hi,
    Thanks for quick reply.but let me tell u my problem in more detail.
    To insert into skill_table I have created a VO that contains ResourceNo, track_id, module_id,skill_type,skill_rating,experience. And I drag it on ADF creation form and also have created read only LOV for resource_name from resorce_table, LOV for skill_type,skill_rating from Lookup table,
    And mapped those LOV to resource_no,skill_type,skill_rating on insert page.
    For track_id I have converted inputtextBox to SelectinputText to create databound LOV which will popup a window that contain master detail for track_table and module_table which shows all track_names in master and corresponding module_names in detail table, and on that window I have select button when we click that button selected track_id and selected module_id will get populated to insert skill page in track_id selectinputtextbox and module_Id inpiuttextbox.
    Now what I want is that instead of track_id and module_id populated on insert page coz these are of id's actually and we want to show values of these id's from other tables, I need to show selected track_name and module_name over on insert page.
    Not getting any idea how to do that???
    Plz help.

  • 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?

  • How to insert data in tables using loops sql

    Oracle 10.2g
    using Oracle sql*plus
    Table student is
    create table student(id)
    as
    select distinct student_id
    from students_table;now
    desc student; will retrieve
    student
    ======
    Name         Null?    Type
    ===========================
    ID                  VARCHAR2(10)Now creating a sequence
    create sequence st_seq;
    alter table student add column no;
    select * from student
    no       id
    =========
            234
            298
    This is the main part
    There are 100 student id in the table
    now i want to populate the table with sequences using seq.next_val
    how to use a loop to insert 100 auto generated numbers in the table.
    Thank you.
    Expected result
    Select * from student
    no     id
    =========
    1     234
    2     298
    .........Why i am doing this way instead of
    create table student(no,id)
    as
    select st_se.nextval,student_id
    from students;This will cause duplication of upn
    using distinct would throw an error.
    create table student(st_id,id)
    as select distinct st_seq.nextval,academicyear
    from student
    as select distinct st_seq.nextval,academicyear
    ERROR at line 2:
    ORA-02287: sequence number not allowed hereThank you.

    Follow the example:
    SQL> create table students_table (student_id number);
    Table created.
    SQL> insert into students_table values(10);
    1 row created.
    SQL> insert into students_table values(10);
    1 row created.
    SQL> insert into students_table values(20);
    1 row created.
    SQL> insert into students_table values(30);
    1 row created.
    SQL> insert into students_table values(40);
    1 row created.
    SQL>
    SQL> commit;
    Commit complete.
    SQL> select *
    2 from students_table;
    STUDENT_ID
    10
    10
    20
    30
    40
    SQL> create sequence st_seq;
    Sequence created.
    SQL> create table student(no,id)
    2 as
    3 with distinct_table as
    4 (
    5 select distinct student_id
    6 from students_table
    7 order by student_id
    8 )
    9 select st_seq.nextval, student_id
    10 from distinct_table
    11 ;
    Table created.
    SQL> select *
    2 from student;
    NO ID
    1 10
    2 20
    3 30
    4 40
    SQL>
    Cheers,
    Davide

  • 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 internal table

    I have 3 internal, for example, one of header table, one of item table, one of result table.
    How can i insert header and item into result table.
    Like.
    Insert header-f1 header-f2 item-f1 item-f2 item-f3 into result
    Thanks.

    loop at ititem.
    move-corresponding ititem to itresult.
    read table itheader with key f1 = ititem-f1.
    if sy-subrc = 0.
    move-corresponding itheader to itresult.
    endif.
    append itresult.
    endloop.
    here all the tables are with header line if your table is without header line you have to use explicit work area.
    regards
    shiba dutta

  • 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.

Maybe you are looking for