How to Improve inserts into Template table for Query Processing

Hi guys!
I need your advice. How can i improve inserts into template table (/BI0/0P00000010 for exemple)? In my scenario i forced to load data from cube C_X to cubes C_1, C_2 and C_3.
To get a goal i created a transformations and a DTP process with delta upload to each of cubes (C_1, C_2, C3). And that proccess takes about 3 hours! (it doesn't matter 1.000 or 100.000 records). But when i tried to load data with full update (with a filter) a proccess get data takes about 1 minutes.
I traced process and saw that inserting into template table (which create each time when proccess started) take the longest time. How can i improve it?

Hi Mahendar,
It will require some efforts to investigate it so I propose to open a support ticket with Microsoft (through portal).
Your first question interest me and I am not sure if you are doing proactive or reactive real time reporting. You can try with
HBase for storing and retrieving data. HBase known for providing good read and write speed. If you are not comfortable writing HBase syntax then you can add an abstraction layer i.e. HIVE. It might take little more time when you
query HBase from Hive.
If you are doing real time analytic, then you can choose from Strom and Microsoft Azure Stream Analytic.
Thanks and Regards,  
Sudhir Rawat

Similar Messages

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

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

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

  • How to capture insert into wf_notifications table

    we are building a custom app, which needs to know as soon as a row in insterted into the wf_notifications table, and we want to avod creating a on insert trigger on this table.
    Is there a way to figure out that a row is being inserted into this table without having to write a trigger.
    Thanks
    Tapash

    Oracle Workflow raises a business event oracle.apps.wf.notification.send as soon a notification record is created in WF_NOTIFICATIONS table. This business event has parameters such as NOTIFICATION_ID, RECIPIENT_ROLE etc. If you have access to the notification id you may access all other information from WF_NOTIFICATIONS table.
    You may create a subscription to this business event with On Error -> Skip property so that in case of an error, your subscription does not impact the normal processing of seeded subscriptions. You may have a PLSQL rule function in the subscription to process the logic required when the notification is created.
    Please refer to Oracle Workflow Developer Guide for more information on using Business Event System.
    Hope this helps.
    Vijay

  • How do i insert into temp table

    Hi ALL,
    I have a table APP
    APP_I Acronym Desc
    1 ACC Accounts
    PLTFRM
    swr_pltfrm_i swr_pltfrm_x swr_pltfrm_typ_x
    1 AIX-JAVA Execution
    2 COBOL/BATCH Execution
    3 COBOL/CICS Execution
    4 CONSULTWORKS/MOBILE Delivery
    5 CONSULTWORKS Delivery
    PLTFRM_APP_ENVT
    swr_pltfrm_i app_i
    1 1
    2 1
    3 1
    4 1
    5 1
    I want to create one temporary tab
    TEMP_insert(app_i,desc, acrnymc ,delivery,execution) which have this columns
    App_i desc acrnymc execution
    1 Accounts ACC AIX-JAVA,COBOL/BATCH,COBOL/CICS
    delivery
    CONSULTWORKS,CONSULTWORKS/MOBILE
    How do i insert the row in to the Temp_Insert table based on APP_I as input to my stored procedure.
    Thanks

    hopefully this will help
    dev>declare
      2      cursor c is select empno,ename,job from emp where deptno=20 and rownum<3;
      3      str varchar2(100);
      4  begin
      5      for cur in c loop
      6          str:=str||' '||cur.ename||' '||cur.job;
      7      end loop;
      8      insert into emp_test (ename) VALUES(str);
      9  end; 
    10  /
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    dev>select ename from emp_test;
    ENAME
    SMITH CLERK JONES MANAGER
    [pre                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • NULL values are inserted into interface table for read only columns

    Hi, I developed a custom Integrator where some of the columns has to be displayed as read only in the layout. I am using SQL content to populate the data. When I upload the data NULL values are inserted into table interface? Is there any work around for this?
    Thanks
    Edited by: user593879 on Jan 12, 2010 7:21 PM

    Doesn't WebADI drive you insane at times?
    I must say, when it's all working it looks great and it is very user friendly (end-user that is, NOT for developers!) but before you get to that stage… please please Oracle invest some time making Web ADI a bit more logical an coherent, get the obvious bugs out, please let us not have to update BNE tables anymore to get things done.
    Anyway, I sorted this one out by setting the Width to zero (0) in the Layout. HTH.

  • Insert into one table by query from other table

    Dear sir, i have inserted in to Table A as below:
    ROLE_ID
    USER_ID
    AUTH_STAT
    BRANCH_CODE
    Teller1
    Phearom
    A
    001
    Teller2
    Phearom
    A
    001
    I want to insert the same more value for field ROLE_ID, USER_ID and AUTH_STAT, except BRANCH_CODE must change. Value of field BRANCH_CODE in can query form Table B.
    Kindly give me some idea.
    Thank and Regard.
    Phearom

    7d8870ae-222b-4d73-8251-86f34b1ad49e wrote:
    Dear sir, i have inserted in to Table A as below:
    ROLE_ID
    USER_ID
    AUTH_STAT
    BRANCH_CODE
    Teller1
    Phearom
    A
    001
    Teller2
    Phearom
    A
    001
    I want to insert the same more value for field ROLE_ID, USER_ID and AUTH_STAT, except BRANCH_CODE must change. Value of field BRANCH_CODE in can query form Table B.
    Kindly give me some idea.
    Thank and Regard.
    Phearom
    You don't seem to have taken any notice of the advice given in your last thread: Insert multi row
    about reading Re: 2. How do I ask a question on the forums?
    and following the advice there.
    In fact, I suspect this is just another thread on the same problem.
    Unless you give us the information required, we can't really help

  • How can i insert into dynamic table  ?

    i have regular internal table with data  .
    i have dynamic table <dyn_tab>
    i insert the data from itab
    MOVE-CORRESPONDING ITAB TO <LS_LINE>.
        INSERT <LS_LINE> INTO TABLE <DYN_TABLE>.
    OK  , NOW I WANT TO ADD THE DATA FROM OTHER TABLE
    THAT HOLD THE DATA THAT ALL THE DYNAMIC TAB BUILD FOR
    HOW CAN I DO THIS INSERT  ?
    I NEED TO INSERT "KOSTL" TO MATCH LINE in <DYN_TABLE>
    THIS WHAT I TRIED TO DO :
          SHIFT INDX1 LEFT DELETING LEADING SPACE.
          CONCATENATE 'KOSTL' INDX1 INTO FIELD .
    ASSIGN COMPONENT FIELD  OF STRUCTURE <DYN_TABLE> TO <FS>.
    <FS> = IT_EKKN-KOSTL.
      but i get dump that <FS> not been assign .

    hi, 
    pls chk the sample code below.
    REPORT zmaschl_create_data_dynamic .
    TYPE-POOLS: slis.
    DATA: it_fcat TYPE slis_t_fieldcat_alv,
    is_fcat LIKE LINE OF it_fcat.
    DATA: it_fieldcat TYPE lvc_t_fcat,
    is_fieldcat LIKE LINE OF it_fieldcat.
    DATA: new_table TYPE REF TO data.
    DATA: new_line TYPE REF TO data.
    FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
    <l_line> TYPE ANY,
    <l_field> TYPE ANY.
    * Build fieldcat
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    i_structure_name = 'SYST'
    CHANGING
    ct_fieldcat = it_fcat[].
    LOOP AT it_fcat INTO is_fcat WHERE NOT reptext_ddic IS initial.
    MOVE-CORRESPONDING is_fcat TO is_fieldcat.
    is_fieldcat-fieldname = is_fcat-fieldname.
    is_fieldcat-ref_field = is_fcat-fieldname.
    is_fieldcat-ref_table = is_fcat-ref_tabname.
    APPEND is_fieldcat TO it_fieldcat.
    ENDLOOP.
    * Create a new Table
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = it_fieldcat
    IMPORTING
    ep_table = new_table.
    * Create a new Line with the same structure of the table.
    ASSIGN new_table->* TO <l_table>.
    CREATE DATA new_line LIKE LINE OF <l_table>.
    ASSIGN new_line->* TO <l_line>.
    * Test it...
    DO 30 TIMES.
    ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
    <l_field> = sy-index.
    INSERT <l_line> INTO TABLE <l_table>.
    ENDDO.
    LOOP AT <l_table> ASSIGNING <l_line>.
    ASSIGN COMPONENT 'SUBRC' OF STRUCTURE <l_line> TO <l_field>.
    WRITE <l_field>.
    ENDLOOP.
    Regards
    Anver
    <i>if hlped pls mark points</i>

  • Upload csv file and insert into a table for user

    Hello,
    i want to create a Page on which, the User of my Application can upload a semicolon delimited file and the data of the file should automatically be stored in a table.
    I can upload the file and the file is then stored in the htmldb_application_files table.
    But I do not no how to parse the file....
    Can anyone help me or is there anyone who have done that before?
    Thank you,
    Tim

    Tim...
    Here is what I did in a similar situation.
    Let the user download a csv file to use as an excel turnaround document.
    I check digit the primary key. They are not supposed to touch that column.
    They do their excel thing adding data in columns next to the ones they are updating. They now have the original and new data on the same row in the excel document. They save it on a share drive as a csv. A perl script wakes up and parses the csv. Verify's the check digit, checks that the old values still exist in the table... etc, and then does the update if all is well at the row level. The csv is replaced showing the success or failure of the update on each row.
    Probably lots of other ways to accomplish this but I have gotten years of use out of the script. The original csv can come out of almost any application. Mine come from apex, discoverer and some excel queries.
    Bob

  • Inconsistent inserts into detail table of master-detail form

    Hello,
    [I am not sure if this is a bug or user error, so I've also put this in the bug tracking system.  Apologize for the 'duplication']
    I have a master-detail form: Orders is the master, and Order_Details is the detail. I have noticed some inconsistent behavior when inserting the detail information.
    On occasion, the row will be inserted, and a null value will get inserted into the database for the first column of the detail table; all the other data values will be inserted fine. There doesn't seem to be any pattern to when it happens. I wrote down the following test steps:
    1. Enter new order information and click 'Create'
    2. Click 'Add Row' button so can add order detail info
    3. Enter detail row information
    4. Click 'Add Row' (I do this so I can see the success message that the detail data was actually inserted)
    5. Click 'Apply Changes' at the master level.
    I ran a query on the order details table and saw that the data inserted correctly. Then I ran the following test:
    1. Enter new order information and click 'Create'
    2. Click Add Row button so can add order detail info
    3. Enter detail row information
    4. Click 'Add Row' (success message appears that detail was inserted)
    5. Enter second detail row information
    6. Click 'Add Row' (success message appears that detail was inserted, however, now in the first column of that second detail row - the product name field/column - the data does not appear. I only see my null text value. The data in the first detail row is all correct)
    7. Enter third row detail information
    8. Click 'Add Row' (success message appears that detail was inserted, and this row's information appears correctly, as does the first row's, but the second row is still showing a null value for the product name column)
    9. Click 'Apply Changes' to get out of the form
    A query of the order details table shows that a null value (-) has indeed been inserted into the table for the product name column of the second detail row.
    This behavior also happens when I don't have a null value for the LOV (i.e., it defaults to the first row of the lookup table).
    Has anyone seen this before? Am I entering the data incorrectly?
    Thanks.
    -melissa
    Message was edited by:
    mblakene

    having the some problem. Any help with this ??
    milowski were you able to solve it ? can you share the information.
    Thanks

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

  • Insert into two tables, how to insert multiple slave records

    Hi, I have a problem with insert into two tables wizard.
    The wizard works fine and I can add my records, but I need to enter multiple slave table records.
    My database:
    table: paper
    `id_paper` INTEGER(11) NOT NULL AUTO_INCREMENT,
    `make` VARCHAR(20) COLLATE utf8_general_ci NOT NULL DEFAULT '',
    `model` VARCHAR(20) COLLATE utf8_general_ci NOT NULL DEFAULT '',
    `gsm` INTEGER(11) NOT NULL,
    PRIMARY KEY (`id_paper`)
    table: paper_data
    `id_paper_data` INTEGER(11) NOT NULL AUTO_INCREMENT,
    `id_paper` INTEGER(11) NOT NULL,
    `value` DOUBLE(15,3) NOT NULL,
    `nanometer` INTEGER(11) NOT NULL,
    PRIMARY KEY (`id_paper_data`)
    I need to add multiple fields "value" and "nanometer"
    Current form looks like this:
    Make:
    Model:
    Gsm:
    Value:
    nanometer:
    I need it to look like this:
    Make:
    Model:
    Gsm:
    Value:
    nanometer:
    Value:
    nanometer:
    Value:
    nanometer:
    Value:
    nanometer:
    and so on.
    The field "id_paper" in table paper_data needs to get same id for entire transaction. Also how do I set default values for each field "nanometer" on my form the must be different (370,380,390 etc)?
    Thanks.

    you can find an answer here: http://209.85.129.132/search?q=cache:PzQj57dsWmQJ:www.experts-exchange.com/Web_Development /Software/Macromedia_Dreamweaver/Q_23713792.html+Insert+Into+Two+Tables+Wizard&cd=3&hl=lt& ct=clnk&gl=lt
    This is a copy of the post:
    Hi experts,
    Im using ADDT to design a page that needs to insert one record into a master ALBUMS table, along with three records into a GENRES table, all linked by the primary, auto-incremented ALBUMS. ALBUM_ID.
    Ive tried many different ways of combining the Insert into Multiple Tables wizard and the insert record wizard with Link Transactions, all with no luck.  Either only the album info gets inserted, or a ALBUM_ID cannot be null error from MySQL.  Here is the structure of the tables
    ALBUMS
    ALBUM_ID, INT(11), Primary, Auto_Increment
    alb_name, varchar
    alb_release, YEAR
    USER_ID, int
    alb_image, varchar
    GENRES
    ALBUM_ID, int, NOT NULL
    GENRE_ID, int, NOT NULL
    ID, int, primary, auto-increment
    Many thanks in advance...
    ==========================================================================================
    //remove this line if you want to edit the code by hand
    function Trigger_LinkTransactions(&$tNG) {
      global $ins_genres;
      $linkObj = new tNG_LinkedTrans($tNG, $ins_genres);
      $linkObj->setLink("ALBUM_ID");
      return $linkObj->Execute();
    function Trigger_LinkTransactions2(&$tNG) {
      global $ins_genres2;
      $linkObj = new tNG_LinkedTrans($tNG, $ins_genres2);
      $linkObj->setLink("ALBUM_ID");
      return $linkObj->Execute();
    function Trigger_LinkTransactions3(&$tNG) {
      global $ins_genres3;
      $linkObj = new tNG_LinkedTrans($tNG, $ins_genres3);
      $linkObj->setLink("ALBUM_ID");
      return $linkObj->Execute();
    //end Trigger_LinkTransactions trigger
    //-----------------------Different Section---------------------//
    // Make an insert transaction instance
    //Add Record Genre 1
    $ins_genres = new tNG_insert($conn_MySQL);
    $tNGs->addTransaction($ins_genres);
    $ins_genres->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "VALUE", null);
    $ins_genres->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $detailValidation);
    $ins_genres->setTable("genres");
    $ins_genres->addColumn("GENRE_ID", "NUMERIC_TYPE", "POST", "GENRE_ID");
    $ins_genres->addColumn("ALBUM_ID", "NUMERIC_TYPE", "VALUE", "");
    $ins_genres->setPrimaryKey("ID", "NUMERIC_TYPE");
    // Add Record Genre 2
    $ins_genres2 = new tNG_insert($conn_MySQL);
    $tNGs->addTransaction($ins_genres2);
    $ins_genres2->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "VALUE", null);
    $ins_genres2->setTable("genres");
    $ins_genres2->addColumn("GENRE_ID", "NUMERIC_TYPE", "POST", "GENRE_ID2");
    $ins_genres2->addColumn("ALBUM_ID", "NUMERIC_TYPE", "VALUE", "");
    $ins_genres2->setPrimaryKey("ID", "NUMERIC_TYPE");
    // Add Record Genre 3
    $ins_genres3 = new tNG_insert($conn_MySQL);
    $tNGs->addTransaction($ins_genres3);
    $ins_genres3->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "VALUE", null);
    $ins_genres3->setTable("genres");
    $ins_genres3->addColumn("GENRE_ID", "NUMERIC_TYPE", "POST", "GENRE_ID3");
    $ins_genres3->addColumn("ALBUM_ID", "NUMERIC_TYPE", "VALUE", "");
    $ins_genres3->setPrimaryKey("ID", "NUMERIC_TYPE");
    =========================================================================================
    Hi Aaron,
    Nice job!!
    $ins_albums->registerTrigger("AFTER", "Trigger_LinkTransactions2", 98);
    $ins_albums->registerTrigger("AFTER", "Trigger_LinkTransactions3", 98);
    These lines, right? :-( Sorry I forgot to mention that
    Thanks a lot for the grading!

  • How to dynamic field insert into intenal table?

    hi friends
    this is my urgent requirements .... how to dynamic field insert into internal table if it possible please tell me
    thanks & regards
    pauldharma

    Hi,
    Go through this
    REPORT  yusmm_text1  NO STANDARD PAGE HEADING
                         LINE-SIZE 199.
    T A B L E S
    TABLES: MARA,
            MAKT,
            THEAD.
    GLOBAL TYPE-POOLS
    TYPE-POOLS : SLIS.
       GLOBAL TYPES
    TYPES : BEGIN OF TP_FINAL,
           MATNR TYPE MARA-MATNR,
           BEGRU TYPE MARA-BEGRU,
           MTART TYPE MARA-MTART,
           MAKTX TYPE MAKT-MAKTX,
           SPRAS TYPE MAKT-SPRAS,
           LTXT(2000)  TYPE C ,
           SRNO TYPE N ,
          END OF TP_FINAL.
    TYPES : BEGIN OF TP_T002,
            SPRAS TYPE T002-SPRAS,
            LAISO TYPE T002-LAISO,
            SRNO TYPE N ,
            END OF TP_T002.
    TYPES : BEGIN OF TP_MARA_MAKT,
            MATNR TYPE MARA-MATNR,
            BEGRU TYPE MARA-BEGRU,
            MTART TYPE MARA-MTART,
            SPRAS TYPE MAKT-SPRAS,
            MAKTX TYPE MAKT-MAKTX,
           END OF TP_MARA_MAKT.
    Types: BEGIN OF tp_matnr,
           matnr TYPE mara-matnr,
           END OF tp_matnr.
       GLOBAL ELEMENTARY VARIABLES
    DATA : gv_date TYPE sy-datum.
    DATA : gv_repid TYPE sy-repid.
    DATA : g_var1(10) TYPE C.
    DATA : gv_index TYPE sy-tabix.
    DATA: gv_strg TYPE string,
          gv_strg1(2000) TYPE C.
    DATA : gv_lang TYPE sy-langu.
    DATA : g_v(3) TYPE N .
    DATA : gv_lines(3) TYPE N .
    DATA : gv_var(3) TYPE N .
    DATA : gv_var1(3) TYPE N.
    DATA: gv_str TYPE STRING.
    DATA: gv_str1 TYPE STRING.
    DATA : gv_li TYPE I,
           gv_lit TYPE I,
           gv_lin TYPE I.
    DATA: g_var11(3) TYPE N,
          gv_li1(3) TYPE N,
          g_var2(3) TYPE N.
    DATA : gv_i1 TYPE I.
    DATA : gv_i TYPE I.
    DATA: gl_lenght TYPE I.
       GLOBAL STRUCTURES
    DATA:   T_NEWTABLE TYPE REF TO DATA,
            T_NEWLINE  TYPE REF TO DATA,
            T_FLDCAT1   TYPE SLIS_T_FIELDCAT_ALV,
            T_FLDCAT   TYPE LVC_T_FCAT,
            WA_IT_FLDCAT TYPE LVC_S_FCAT,
            WA_IT_FLDCAT1 TYPE SLIS_FIELDCAT_ALV,
            WA_COLNO(2) TYPE N,
            WA_FLNAME(5) TYPE C,
            L_LT TYPE SLIS_LAYOUT_ALV.
       GLOBAL INTERNAL TABLES (WITH INCLUDE STRUCTURE)
    DATA : IG_MARA_MAKT TYPE STANDARD TABLE OF TP_MARA_MAKT,
           WG_MARA_MAKT TYPE TP_MARA_MAKT.
    DATA : IG_T002 TYPE STANDARD TABLE OF TP_T002,
           WG_T002 TYPE TP_T002.
    DATA : IG_FINAL TYPE STANDARD TABLE OF TP_FINAL,
           WG_FINAL TYPE TP_FINAL.
    data : IG_MATNR TYPE STANDARD TABLE OF TP_MATNR WITH HEADER  LINE,
           WG_MATNR TYPE TP_MATNR.
    DATA:BEGIN OF IG_THEAD OCCURS 0.
            INCLUDE STRUCTURE THEAD .
    DATA: END OF IG_THEAD.
    DATA:BEGIN OF IG_TLINE OCCURS 0.
            INCLUDE STRUCTURE TLINE  .
    DATA:END OF IG_TLINE.
    FIELD-SYMBOLS
    FIELD-SYMBOLS: <T_DYNTABLE> TYPE STANDARD TABLE,"Dynamic internal
                                                            "tablename
                   <FS_DYNTABLE>,  "Field symbol to create work area
                  <FS_FLDVAL> TYPE ANY.   " Field symbol to assign values
    COMPULSORY
    FIELD-SYMBOLS: <FS_DATA> TYPE REF TO DATA,
                   <FS_DATA1> TYPE REF TO DATA,
                   <FS_2>    TYPE STANDARD TABLE,
                   <FS_22>   TYPE STANDARD TABLE,
                   <FS_1>,
                   <FS_11>,
                   <F>,
                   <FA>,
                   <LWA_LINE_WA>,
                   <LWA_LINE_WA1>.
    ------- Create Dyn Table From FC
    DATA: LT_DATA        TYPE   REF TO DATA,
          LT_DATA1        TYPE   REF TO DATA,
          LWA_LINE       TYPE   REF TO  DATA,
          LWA_LINE1       TYPE   REF TO  DATA,
          LI_FIELD_CAT   TYPE   LVC_T_FCAT,
          LWA_FIELD_CAT  TYPE   LVC_S_FCAT.
       PARAMETERS & SELECT-OPTIONS
    SELECTION-SCREEN : BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS : S_SPRAS FOR MAKT-SPRAS NO INTERVALS  DEFAULT 'EN'
                                                            OBLIGATORY ,
                     S_MATNR FOR MARA-MATNR,
                     S_MTART FOR MARA-MTART.
    PARAMETERS: GP_SIZE TYPE I DEFAULT '200'.
    SELECTION-SCREEN : END OF BLOCK B1.
       INITIALIZATION
    INITIALIZATION.
      gv_repid = sy-repid.
      gv_date = sy-datum.
    AT SELECTION-SCREEN
    AT SELECTION-SCREEN.
      IF GP_SIZE < 0.
       MESSAGE E002(00).
      ENDIF.
      IF GP_SIZE > 50000.
       MESSAGE W130(26) WITH TEXT-004.
        SET CURSOR FIELD 'gp_size'.
      ENDIF.
    START-OF-SELECTION
    START-OF-SELECTION.
      PERFORM FIELDCAT.
      PERFORM LAYOUT.
      PERFORM DATA_FETCH.
      PERFORM READ_DATA_TO_FINAL.
      SORT ig_final BY matnr spras.
      gv_lin = gv_li.
      gv_li = gv_li - 2.
      LOOP AT ig_final INTO wg_final.
        ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = 'Material Number'.
        ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = 'Authorization Group'.
        g_VAR11 = wg_final-srno + 2.
        gv_li1 = gv_li1 + 2.
        MOVE : g_var11 TO gv_i1.
        ASSIGN COMPONENT g_var11 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = 'MatDesc'.
        g_var2 = g_var11 + gv_lines.
        ASSIGN COMPONENT g_var2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = 'BasicData'.
        APPEND <LWA_LINE_WA1> TO <FS_22>.
        EXIT.
       ENDLOOP.
      LOOP AT ig_final INTO wg_final.
        AT NEW matnr.
          gv_index = sy-tabix.
          ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA> TO <F>.
          <F> = wg_final-matnr.
          ENDAT.
        AT NEW MATNR.
        GV_INDEX = SY-TABIX.
        ASSIGN COMPONENT 1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = wg_final-matnr.
         ENDAT.
        ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA> TO <F>.
        <F> = wg_final-begru.
        ASSIGN COMPONENT 2 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = wg_final-begru.
        gv_var = wg_final-srno + 2.
        gv_li = gv_li + 2.
        MOVE : gv_var TO gv_i.
        ASSIGN COMPONENT gv_var OF STRUCTURE <LWA_LINE_WA> TO <F>.
        <F> = wg_final-maktx.
        ASSIGN COMPONENT gv_var OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = wg_final-maktx.
        gv_var1 = gv_var + gv_lines  .
        ASSIGN COMPONENT gv_var1 OF STRUCTURE <LWA_LINE_WA> TO <F>.
       <F> = wg_final-ltxt.
        ASSIGN COMPONENT gv_var1 OF STRUCTURE <LWA_LINE_WA1> TO <FA>.
        <FA> = wg_final-ltxt.
        AT END OF matnr.
          APPEND <LWA_LINE_WA> TO <FS_2>.
          CLEAR <LWA_LINE_WA>.
        ENDAT.
        AT END OF matnr.
         APPEND <LWA_LINE_WA1> TO <FS_22>.
         CLEAR <LWA_LINE_WA1>.
        ENDAT.
      ENDLOOP.
      PERFORM display..
    *&      Form  data_fetch
          text
    -->  p1        text
    <--  p2        text
    FORM DATA_FETCH .
      SELECT matnr
              from mara up to gp_size rows
             appending corresponding fields of table ig_matnr
             where matnr in s_matnr
             and mtart in s_mtart.
    loop at ig_matnr.
      SELECT  MARA~MATNR
              MARA~BEGRU
              MARA~MTART
              MAKT~SPRAS
              MAKT~MAKTX FROM MARA INNER JOIN MAKT
        ON MARAMATNR = MAKTMATNR
       appending corresponding fields of TABLE ig_mara_makt  UP TO GP_SIZE
    ROWS
        WHERE makt~spras IN s_spras
        AND   mara~matnr IN s_matnr
        AND   mara~mtart IN s_mtart
        AND   mara~matnr EQ ig_matnr-matnr.
        endloop.
      IF sy-subrc = 0.
        SORT ig_mara_makt.
      ENDIF.
    ENDFORM.                    " data_fetch
    *&      Form  read_data_to_final
          text
    -->  p1        text
    <--  p2        text
    FORM READ_DATA_TO_FINAL .
      LOOP AT ig_mara_makt INTO wg_mara_makt .
        wg_final-MATNR = wg_mara_makt-MATNR.
        wg_final-BEGRU = wg_mara_makt-BEGRU.
        wg_final-MTART = wg_mara_makt-MTART.
        wg_final-SPRAS = wg_mara_makt-SPRAS.
        wg_final-MAKTX = wg_mara_makt-MAKTX.
        READ TABLE ig_t002 INTO wg_t002 WITH KEY spras = wg_final-spras.
        IF sy-subrc = 0.
          wg_final-srno = wg_t002-srno.
        ENDIF.
        CLEAR ig_thead[].
        ig_thead-TDOBJECT = 'MATERIAL'.
        ig_thead-TDNAME   = wg_final-matnr.
        ig_thead-TDID     = 'GRUN'.
        ig_thead-TDSPRAS  = wg_final-spras.
        CALL FUNCTION 'TEXT_READ'
          EXPORTING
            I_HEADER   = IG_THEAD
            I_READONLY = 'X'
          IMPORTING
            E_HEADER   = IG_THEAD
          TABLES
            T_LINES    = IG_TLINE[]
          EXCEPTIONS
            NOTFOUND   = 1.
        IF sy-subrc  EQ 0.
          LOOP AT  ig_tline.
            gv_strg = ig_tline-tdline.
            IF gv_strg1 <> ' '.
              CONCATENATE gv_strg1 ';' gv_strg INTO gv_strg1.
            ELSE.
              gv_strg1 = gv_strg.
            ENDIF.
          ENDLOOP.
          wg_final-ltxt = gv_strg1.
          APPEND wg_final TO ig_final.
          CLEAR wg_final.
          gv_strg1 = ' '.
        ELSE.
          APPEND wg_final TO  ig_final.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " read_data_to_final
    " read_data_to_final
    *&      Form  layout
          text
    -->  p1        text
    <--  p2        text
    FORM LAYOUT .
      CLEAR L_LT.
      L_LT-ZEBRA = 'X'.
      L_LT-COLWIDTH_OPTIMIZE = 'X'.
      L_LT-WINDOW_TITLEBAR = 'MATERIAL DETAILS'.
    ENDFORM.                    " layout
    *&      Form  fieldcat
          text
    -->  p1        text
    <--  p2        text
    FORM FIELDCAT .
      SELECT SPRAS
               LAISO FROM t002 INTO  CORRESPONDING FIELDS OF TABLE ig_t002
          WHERE spras IN s_spras.
      DESCRIBE TABLE ig_t002 LINES gv_lines.
      LOOP AT ig_t002 INTO wg_t002.
        g_v = g_v + 1.
        Wg_t002-srno = g_v.
        MODIFY ig_t002 FROM wg_t002 TRANSPORTING SRNO.
      ENDLOOP.
      LOOP AT ig_t002 INTO wg_t002.
        CLEAR WA_IT_FLDCAT.
        MOVE SY-INDEX TO WA_COLNO.
        CONCATENATE 'MD-' wg_t002-LAISO
                          WA_COLNO
                         INTO WA_FLNAME.
        WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
        WA_IT_FLDCAT-DATATYPE = 'CHAR'.
        WA_IT_FLDCAT-SELTEXT = WA_FLNAME.
        WA_IT_FLDCAT-INTLEN = 250.
        WA_IT_FLDCAT-TABNAME = '<FS_2>'.
        APPEND WA_IT_FLDCAT TO T_FLDCAT.
        CLEAR wg_t002.
        ENDLOOP.
      LOOP AT ig_t002 INTO wg_t002.
        CLEAR WA_IT_FLDCAT.
        MOVE SY-INDEX TO WA_COLNO.
        CONCATENATE 'BD-' wg_t002-LAISO
                           WA_COLNO
                        INTO WA_FLNAME.
        WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
        WA_IT_FLDCAT-DATATYPE = 'CHAR'.
        WA_IT_FLDCAT-SELTEXT = WA_FLNAME.
        WA_IT_FLDCAT-INTLEN = 250.
        WA_IT_FLDCAT-TABNAME = '<FS_2>'.
        APPEND WA_IT_FLDCAT TO T_FLDCAT.
        CLEAR wg_t002.
        ENDLOOP.
      MOVE 'MATNR' TO WA_FLNAME.
      WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
      WA_IT_FLDCAT-DATATYPE = 'CHAR'.
      WA_IT_FLDCAT-SELTEXT = 'Material No'.
      WA_IT_FLDCAT-INTLEN = 18.
      WA_IT_FLDCAT-TABNAME = '<FS_2>'.
      INSERT WA_IT_FLDCAT INTO T_FLDCAT INDEX 1.
      MOVE 'BEGRU' TO WA_FLNAME.
      WA_IT_FLDCAT-FIELDNAME = WA_FLNAME.
      WA_IT_FLDCAT-DATATYPE = 'CHAR'.
      WA_IT_FLDCAT-SELTEXT = 'Authorization Group'.
      WA_IT_FLDCAT-INTLEN = 4.
      WA_IT_FLDCAT-TABNAME = '<FS_2>'.
      INSERT WA_IT_FLDCAT INTO T_FLDCAT INDEX 2.
      DESCRIBE TABLE T_FLDCAT LINES gv_li.
      ASSIGN LT_DATA TO <FS_DATA>.
    Creating the Dynamic Internal Table
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG           = T_FLDCAT         " Fieldcatalogue
        IMPORTING
          EP_TABLE                  = <FS_DATA>   " Dynamic Internal Table
        EXCEPTIONS
          GENERATE_SUBPOOL_DIR_FULL = 1
          OTHERS                    = 2.
    Assign Dyn Table To Field Sumbol
      ASSIGN <FS_DATA>->* TO <FS_1>.
    Assigning the Internal Table TYPE ANY to Standard internal Table
      ASSIGN <FS_1> TO <FS_2>.
    Creating a Workarea
      CREATE DATA LWA_LINE LIKE LINE OF <FS_2> .
    Assigning the Content to the workares as a Pointer
      ASSIGN LWA_LINE->* TO <LWA_LINE_WA>.
      LOOP AT T_FLDCAT INTO WA_IT_FLDCAT.
        WA_IT_FLDCAT1-FIELDNAME = WA_IT_FLDCAT-FIELDNAME.
        WA_IT_FLDCAT1-TABNAME =  WA_IT_FLDCAT-TABNAME.
        WA_IT_FLDCAT1-SELTEXT_L = WA_IT_FLDCAT-SELTEXT.
       WA_IT_FLDCAT1-REF_TABNAME = 'MARC'.
        APPEND WA_IT_FLDCAT1 TO T_FLDCAT1.
        CLEAR : WA_IT_FLDCAT,WA_IT_FLDCAT1.
      ENDLOOP.
      ASSIGN LT_DATA1 TO <FS_DATA1>.
      CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
        EXPORTING
          IT_FIELDCATALOG           = T_FLDCAT         " Fieldcatalogue
        IMPORTING
          EP_TABLE                  = <FS_DATA1>  " Dynamic Internal table
        EXCEPTIONS
          GENERATE_SUBPOOL_DIR_FULL = 1
          OTHERS                    = 2.
    Assign Dyn Table To Field Sumbol
      ASSIGN <FS_DATA1>->* TO <FS_11>.
    Assigning the Internal Table TYPE ANY to Standard internal Table
      ASSIGN <FS_11> TO <FS_22>.
    Creating a Workarea
      CREATE DATA LWA_LINE1 LIKE LINE OF <FS_22> .
    Assigning the Content to the workares as a Pointer
      ASSIGN LWA_LINE1->* TO <LWA_LINE_WA1>.
    ENDFORM.                    " fieldcat
    *&      Form  show
          text
    -->  p1        text
    <--  p2        text
    FORM Display .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
       I_INTERFACE_CHECK                 = ' '
       I_BYPASSING_BUFFER                = ' '
       I_BUFFER_ACTIVE                   = ' '
         I_CALLBACK_PROGRAM                = GV_REPID
        I_CALLBACK_PF_STATUS_SET          = 'PF_STATUS_SET'
        I_CALLBACK_USER_COMMAND           = 'USER_COMMAND'
       I_CALLBACK_TOP_OF_PAGE            = ' '
       I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
       I_CALLBACK_HTML_END_OF_LIST       = ' '
       I_STRUCTURE_NAME                  =
       I_BACKGROUND_ID                   = ' '
       I_GRID_TITLE                      =
       I_GRID_SETTINGS                   =
        IS_LAYOUT                         = L_LT
         IT_FIELDCAT                       = T_FLDCAT1[]
       IT_EXCLUDING                      =
       IT_SPECIAL_GROUPS                 =
       IT_SORT                           =
       IT_FILTER                         =
       IS_SEL_HIDE                       =
       I_DEFAULT                         = 'X'
       I_SAVE                            = ' '
       IS_VARIANT                        =
       IT_EVENTS                         =
       IT_EVENT_EXIT                     =
       IS_PRINT                          =
       IS_REPREP_ID                      =
       I_SCREEN_START_COLUMN             = 0
       I_SCREEN_START_LINE               = 0
       I_SCREEN_END_COLUMN               = 0
       I_SCREEN_END_LINE                 = 0
       I_HTML_HEIGHT_TOP                 = 0
       I_HTML_HEIGHT_END                 = 0
       IT_ALV_GRAPHICS                   =
       IT_HYPERLINK                      =
       IT_ADD_FIELDCAT                   =
       IT_EXCEPT_QINFO                   =
       IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
       E_EXIT_CAUSED_BY_CALLER           =
       ES_EXIT_CAUSED_BY_USER            =
        TABLES
          T_OUTTAB                          = <FS_2>
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
      IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " display
    FORM PF_STATUS_SET USING RS_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'DISPLAY' .
    ENDFORM. "PF_STATUS_SET
    *& Form Name: user_command *
    *& Form Desc: For Handling USER_COMMAND *
    FORM USER_COMMAND USING IF_UCOMM TYPE SY-UCOMM
                         IS_SELFIELD TYPE SLIS_SELFIELD.
      CASE IF_UCOMM.
        WHEN 'DOWNLOAD'.
          CALL FUNCTION 'POPUP_TO_CONFIRM'
            EXPORTING
      TITLEBAR                    = ' '
      DIAGNOSE_OBJECT             = ' '
              TEXT_QUESTION               = 'Data download to excel'
      TEXT_BUTTON_1               = 'Ja'(001)
      ICON_BUTTON_1               = ' '
      TEXT_BUTTON_2               = 'Nein'(002)
      ICON_BUTTON_2               = ' '
      DEFAULT_BUTTON              = '1'
      DISPLAY_CANCEL_BUTTON       = 'X'
      USERDEFINED_F1_HELP         = ' '
      START_COLUMN                = 25
      START_ROW                   = 6
      POPUP_TYPE                  =
    IMPORTING
      ANSWER                      =
    TABLES
      PARAMETER                   =
    EXCEPTIONS
      TEXT_NOT_FOUND              = 1
      OTHERS                      = 2
          IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
        BIN_FILESIZE                  =
              FILENAME                     = 'C:\Material-Text.xls'
             FILETYPE                      = 'ASC'
        APPEND                        = ' '
         WRITE_FIELD_SEPARATOR         = 'X'
        HEADER                        = '00'
         TRUNC_TRAILING_BLANKS         = 'X'
        WRITE_LF                      = 'X'
        COL_SELECT                    = ' '
        COL_SELECT_MASK               = ' '
         DAT_MODE                      = 'X'
       IMPORTING
         FILELENGTH                    = GL_LENGHT
            TABLES
              DATA_TAB                      = <FS_22>
      EXCEPTIONS
        FILE_WRITE_ERROR              = 1
        NO_BATCH                      = 2
        GUI_REFUSE_FILETRANSFER       = 3
        INVALID_TYPE                  = 4
        NO_AUTHORITY                  = 5
        UNKNOWN_ERROR                 = 6
        HEADER_NOT_ALLOWED            = 7
        SEPARATOR_NOT_ALLOWED         = 8
        FILESIZE_NOT_ALLOWED          = 9
        HEADER_TOO_LONG               = 10
        DP_ERROR_CREATE               = 11
        DP_ERROR_SEND                 = 12
        DP_ERROR_WRITE                = 13
        UNKNOWN_DP_ERROR              = 14
        ACCESS_DENIED                 = 15
        DP_OUT_OF_MEMORY              = 16
        DISK_FULL                     = 17
        DP_TIMEOUT                    = 18
        FILE_NOT_FOUND                = 19
        DATAPROVIDER_EXCEPTION        = 20
        CONTROL_FLUSH_ERROR           = 21
        OTHERS                        = 22
          IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          IF GL_LENGHT NE 0.
            MESSAGE S398(00) WITH 'DATA downloaded to EXCEL'.
          ENDIF.
    Thanks
      ENDCASE.
    ENDFORM.                    "user_command

  • How do i insert into more than one table from temp table?

    Hi,
    I have three tables such as temp,stck and stol
    temp table contains data as below. It has 22 columns.
    STOCK     STOCKDESC     ALIAS1     ALIAS2     ALIAS3     ALIAS4     ALIAS5     ALIAS6     ALIAS7     ALIAS8     ALIAS9     ALIAS10     ALIAS11     ALIAS12     ALIAS13     ALIAS14     ALIAS15     ALIAS16     ALIAS17     ALIAS18     ALIAS19     ALIAS20
    bmg667691031      NOWE FINANSE LTD     yy     zz     B282DV3      TESTICKER      te     te1     bmg667691031BM     te     707943W     ex     IR-PRIME     IR-ALTID     IR-BLOOM     NT-PRIME     NT-ALTID     NT-BLOOM     AU-PRIME     AU-ALTID     AU-BLOOM     mm
    AA0098000181      UFACEX HOLDINGS VAR RT DUE 06-30-2010     kk     yy     mm     TESTICKER      aa     ff     AA0098000181GB     bb     031969W     cc     IR-PRIME     IR-ALTID     IR-BLOOM     NT-PRIME     NT-ALTID     NT-BLOOM     AU-PRIME     AU-ALTID     AU-BLOOM     ba
    AC1350Z7M923      CDA GOVT TREAS BILLS CDS- 08-05-2010     ee     ff     gg     TESTICKER      hh     ij     AC1350Z7M923CA     mn     1A1MTLU     op     IR-PRIME     IR-ALTID     IR-BLOOM     NT-PRIME     NT-ALTID     NT-BLOOM     AU-PRIME     AU-ALTID     AU-BLOOM     op
    stck table contains as below.It has six columns. But always first three columns will have values.
    stock_id   stock_code stock_description              stock_type terriory_code preferred code
    1185072     AED                    
    1185073     ARA     CURRENCY ARGENTINA PESO               
    1185074     ATS     CURRENCY AUSTRIAN SCHS     
    stol table contains as below. It has 6 columns.Terriory_code is always empty.
    stock_code        territory_code    stol_type stock_id  stck_code_type sys_entry_date
    AED          0 1185072     0     6/22/2007 3:59:13.000 PM
    ARA          0 1185073     0     6/22/2007 3:59:13.000 PM
    ATS          0     1185074     0     6/22/2007 3:59:13.000 PM
    Now, i want to insert into stck and stol table based on temp table records. constraints to insert into stck and stol tables are as below
    In temp table first column is called stock. This stock has to compare with stck table stock_code. If it is not present in stck table, then it has to insert into stck table with stock_id and stock_description. Here, I need to generate stock_id my self in the code.
    In temp table, column 3 to column 22, i have alias. Each column has to check with stol table stock_code column. For instance, column3 check with stock_code column. Then column4 check with stock_code. If stock_code is not present in stol table, then i have to insert into stol table.
    I need to generate stock,id in the code. How do i perform this insertion?
    Edited by: user12852882 on Jun 12, 2010 2:37 AM

    It can be done using SQL (no loops required)
    insert into stock_table (stock_id,stock_code,stock_description)
    select stock_id,get_stock_code,stockdesc  /* get_stock_code is a function providing stock_code - usually a sequence value */
      from (select t.stock stock_id,t.stockdesc,s.stock_id stock_stock_id
              from temp_table t,stock_table s
             where t.stock = s.stock_id(+)
    where s.stock_id is null;
    insert into stol_table (stock_code,sys_entry_date) /* not clear where other values to be inserted will come from */
    select stock_code,sysdate
      from (select t.stock_code,s.stock_code stol_stock_code
              from (select distinct stock_code
                      from (select alias1 stock_code from temp_table union all
                            select alias2 from temp_table union all
                            select alias3 from temp_table union all
                            select alias4 from temp_table union all
                            select alias5 from temp_table union all
                            select alias6 from temp_table union all
                            select alias7 from temp_table union all
                            select alias8 from temp_table union all
                            select alias9 from temp_table union all
                            select alias10 from temp_table union all
                            select alias11 from temp_table union all
                            select alias12 from temp_table union all
                            select alias13 from temp_table union all
                            select alias14 from temp_table union all
                            select alias15 from temp_table union all
                            select alias16 from temp_table union all
                            select alias17 from temp_table union all
                            select alias18 from temp_table union all
                            select alias19 from temp_table union all
                            select alias20 from temp_table
                           )                                           /* use unpivot instead if you are 11g */
                     where stock_code is not null
                   ) t,stol_table s
             where t.stock_code = s.stock_code(+)
    where s.stock_code is null;
    and think about damorgan's post, you'll never regret it (especially when you will not just think)
    Regards
    Etbin

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

Maybe you are looking for