Load the data from table to table index

Hello

We need to load index per table to table data. The code below works fine.

declare
query varchar2(200);
Type l_emp is TABLE OF emp%rowtype INDEX BY Binary_Integer;
rec_1 l_emp;

begin
query :=' SELECT * FROM emp';
 EXECUTE IMMEDIATE query BULK COLLECT INTO rec_1 ;

For ALL  i   in rec_1 .First .. rec_1 .Last
Insert Into emp_b
        values rec_1 (i);
end;
/

But data from the source table and the target table are dynamic.

Ex:

In code, above table emp (source) and target is emp_b are static.

But for our scenario is dependent on the source table, target would change as below.

If source is emp target is emp_b

If source is emp1 target is emp_b1...

create or replace procedure p(source in varchar2, target in varchar2)
as
query varchar2(200);
source varchar2(200);
Type l_emp is TABLE OF emp%rowtype INDEX BY Binary_Integer;
rec_1 l_emp;

begin
query :=' SELECT * FROM ' || source;
 EXECUTE IMMEDIATE query BULK COLLECT INTO rec_1 ;

For ALL i   in rec_1 .First .. rec_1 .Last
 execute immediate 'INSERT INTO ' || target || ' values ' ||rec_1(i);
end;
/


His throw. How to implement this scenario... Please help with that?

No particular reason to use to COLLECT EVERYTHING & BULK here? Why not ordinary

INSERT INTO target
SELECT * FROM source;

However if that's what you need you need a dynamic PLSQL block, which comes with additional side effects (code SQL injection). Dynamic SQL is not here.

Kind regards

Tags: Database

Similar Questions

  • Generic procedure to load the data from the source to the table target

    Hi all

    I want to create a generic procedure to load data of X number of the source table to X number of the target table.

    such as:

    Source1-> Target1

    Source2-> Target2

    -> Target3 Source3

    Each target table has the same structure as the source table.

    The indexes are same as well. Constraint are not predefined in the source or target tables.there is no involved in loading the data from the business logic.

    It would simply add.

    This procedure will be scheduled during off hours and probably only once in a month.

    I created a procedure that does this, and not like:

    (1) make a contribution to the procedure as Source and target table.

    (2) find the index in the target table.

    (3) get the metadata of the target table indexes and pick up.

    (4) delete the index above.

    (5) load the data from the source to the target (Append).

    (6) Re-create the indexes on the target table by using the collection of meta data.

    (7) delete the records in the source table.

    sample proc as: (logging of errors is missing)

    CREATE or REPLACE PROCEDURE PP_LOAD_SOURCE_TARGET (p_source_table IN VARCHAR2,

    p_target_table IN VARCHAR2)

    IS

    V_varchar_tbl. ARRAY TYPE IS VARCHAR2 (32);

    l_varchar_tbl v_varchar_tbl;

    TYPE v_clob_tbl_ind IS TABLE OF VARCHAR2 (32767) INDEX OF PLS_INTEGER;

    l_clob_tbl_ind v_clob_tbl_ind;

    g_owner CONSTANT VARCHAR2 (10): = 'STG '.

    CONSTANT VARCHAR2 G_OBJECT (6): = 'INDEX ';

    BEGIN

    SELECT DISTINCT INDEX_NAME BULK COLLECT

    IN l_varchar_tbl

    OF ALL_INDEXES

    WHERE table_name = p_target_table

    AND the OWNER = g_owner;

    FOR k IN l_varchar_tbl. FIRST... l_varchar_tbl. LAST LOOP

    SELECT DBMS_METADATA. GET_DDL (g_object,

    l_varchar_tbl (k),

    g_owner)

    IN l_clob_tbl_ind (k)

    FROM DUAL;

    END LOOP;

    BECAUSE me IN l_varchar_tbl. FIRST... l_varchar_tbl. LAST LOOP

    RUN IMMEDIATELY "DROP INDEX ' |" l_varchar_tbl (i);

    DBMS_OUTPUT. PUT_LINE (' INDEXED DROPED AS :'|| l_varchar_tbl (i));

    END LOOP;

    RUN IMMEDIATELY ' INSERT / * + APPEND * / INTO ' | p_target_table |

    ' SELECT * FROM ' | '. p_source_table;

    COMMIT;

    FOR s IN l_clob_tbl_ind. FIRST... l_clob_tbl_ind LAST LOOP.

    EXECUTE IMMEDIATE l_clob_tbl_ind (s);

    END LOOP;

    RUN IMMEDIATELY 'TRUNCATE TABLE ' | p_source_table;

    END PP_LOAD_SOURCE_TARGET;

    I want to know:

    1 has anyone put up a similar solution if yes what kind of challenges have to face.

    2. it is a good approach.

    3. How can I minimize the failure of the data load.

    Why not just

    create table to check-in as

    Select "SOURCE1" source, targets "TARGET1", 'Y' union flag double all the

    Select "SOURCE2', 'TARGET2', 'Y' in all the double union

    Select "SOURCE3', 'Target3', 'Y' in all the double union

    Select "SOURCE4', 'TARGET4', 'Y' in all the double union

    Select 'Source.5', 'TARGET5', 'Y' in double

    SOURCE TARGET FLAG
    SOURCE1 TARGET1 THERE
    SOURCE2 TARGET2 THERE
    SOURCE3 TARGET3 THERE
    SOURCE4 TARGET4 THERE
    SOURCE.5 TARGET5 THERE

    declare

    the_command varchar2 (1000);

    Start

    for r in (select source, target of the archiving of the pavilion where = 'Y')

    loop

    the_command: = "insert / * + append * / into ' |" r.Target | ' Select * from ' | '. r.source;

    dbms_output.put_line (the_command);

    -execution immediate the_command;

    the_command: = 'truncate table ' | r.source | "drop storage."

    dbms_output.put_line (the_command);

    -execution immediate the_command;

    dbms_output.put_line(r.source ||) 'table transformed');

    end loop;

    end;

    Insert / * + append * / into select destination1 * source1

    truncate table SOURCE1 drop storage

    Treated SOURCE1 table

    Insert / * + append * / to select TARGET2 * in SOURCE2

    truncate table SOURCE2 drop storage

    Treated SOURCE2 table

    Insert / * + append * / into select target3 * of SOURCE3

    truncate table SOURCE3 drop storage

    Treated SOURCE3 table

    Insert / * + append * / into TARGET4 select * from SOURCE4

    truncate table SOURCE4 drop storage

    Table treated SOURCE4

    Insert / * + append * / into TARGET5 select * from source.5

    truncate table source.5 drop storage

    Treated source.5 table

    Concerning

    Etbin

  • Load the data from a text file into a table using pl/sql

    Hi Experts,

    I want to load the data from a text file (sample1.txt) to a table using pl/sql

    I used the pl/sql code below

    ***********************************
    declare
    f utl_file.file_type;
    s varchar2 (200);
    c number: = 0;
    Start
    f: = utl_file.fopen('TRY','sample1.txt','R');
    loop
    UTL_FILE.get_line (f, s);
    insert into sampletable (a, b, c) values (s, s, s);
    c: = c + 1;
    end loop;
    exception
    When NO_DATA_FOUND then
    UTL_FILE.fclose (f);
    dbms_output.put_line('No. deles de lignes insérées: ' || c);
    end;

    ***************************************

    and my sample1.txt file looks like

    ***************************************
    1
    2
    3
    ***************************************

    Gets the data inserted, with way below

    Select * from sampletable;

    A, B AND C

    1-1-1
    2-2-2
    3 3 3

    I want that data to get inserted as

    A, B AND C

    1 2 3

    The text file I have is to have three lines, and the first value of each line should go to each column

    Help, please...

    Thank you
    declare
    f utl_file.file_type;
    s1 varchar2(200);
    s2 varchar2(200);
    s3 varchar2(200);
    c number := 0;
    begin
    f := utl_file.fopen('TRY','sample1.txt','R');
    utl_file.get_line(f,s1);
    utl_file.get_line(f,s2);
    utl_file.get_line(f,s3);
    insert into sampletable (a,b,c) values (s1,s2,s3);
    c := c + 1;
    utl_file.fclose(f);
    exception
    when NO_DATA_FOUND then
    if utl_file.is_open(f) then utl_file.fclose(f); ens if;
    dbms_output.put_line('No. of rows inserted : ' || c);
    end;
    

    SY.

  • What is the fastest way bulk load the data from ACE / 400 to Oracle?

    Asked me to move data from the AS / 400 to Oracle11gR2 as fast that ODI may eventually. Quinte just no mapping, no transformation, no membership.

    An ODI11g agent is started on the computer of Oracle target, but being new ODI, I don't know how to use SQL for Oracle LKM loading in a scene and then updated incremental Oracle IKM layout from staging to the target table.

    It took 50 minutes to move recorded about 4 million. I need to get this in about 10 minutes. So guys, if there is a best practice to do this, please let me know, but now I'll try any suggestion you might think.

    Thank you in advance.

    Means the faster is to use a combination of ODI interface and ODI tool named OdiSqlUnload.
    N ° 1). Use the ODI OdiSqlUnload tool to export the data from the AS / 400 files in a flat file of the BONES.
    Step 2.) Use this flat file as source and LKM file for Oracle (SQLLDR) and Oracle IKM incremental update to load Oracle data.

    Your current path is slow because it operates on a row by row basis.

  • Load the data from txt

    Hello

    I just export the data in my cube, he geneates two text because of this file is more than 2 GB in size, one is xxxxx.txt, another is xxxxx_1.txt.

    My question is that if I load the data file above in the same cube, I should just specify the first file xxxxx.txt? It seems that I can't specify both text files?

    Thank you

    you only need to load the second file
    Or
    clear data and load the two

    Your choice, you will get the same results.

  • Need help to load the data from the Excel data to oracle tables

    I need to load an Excel worksheet to the Oracle table.

    The worksheet contains 20 columns, the first 8 columns contains basic information, but the rest 12 columns contains info like
    1stQtr_08, 2ndQtr_08, 3rdQtr_08, 4thQtr_08
    1stQtr_09, 2ndQtr_09, 3rdQtr_09, 4thQtr_09
    1stQtr_10, 2ndQtr_10, 3rdQtr_10, 4thQtr_10

    So what I have to do is:

    break only one record (with 20 fields) in Excel to 3 files for each fiscal year in the Oracle table for each record in the database table will look like

    8 base field + fiscal_year + 1stQtr_08, 2ndQtr_08, 3rdQtr_08, 4thQtr_08
    8 base field + fiscal_year + 1stQtr_09, 2ndQtr_09, 3rdQtr_09, 4thQtr_09
    8 base field + fiscal_year + 1stQtr_10, 2ndQtr_10, 3rdQtr_10, 4thQtr_10

    There are about 10000 rows in the data file, so how can I use sqlldr to perform this task? beside sqlldr, other good suggestions?

    THX

    External tables is just an API Oracle sqlloader. If you are about to load this data over and over again, the external tables would be a good idea, but if it's a one time thing, sqlldir is more simple, unless you want to just learn to use external Tables.

    I used to run a data warehouse, so I did it, the less similar to what you do in the past.

  • Can we use Source accounting entity group to load the data from multiple entities with a single rule to load?


    Page 79 of erpi_admin_11123200.pdf says that "reporting entity groups are used to extract data from several reporting entities in a single data rule execution.  I use standard EBS adapter to load data in HFM application, I created a group of entity made up of several accounting entities, but I can't find a place in FDMEE where you get to select/use this group... When you define an import format you type the name and select Source (e, g. EBS) system you can select Map Source (for example EBS11 I adapter) or the accounting entity (it is what I select to define data load maps), but not both.  Note that there is no place to select the Group of accounting entity...  Location check menu group entity drop-down but it doe not my group of accounting entity which I believe is anyway something different... and creating a location and pointing to a format compatible with the selected Source adapter is no not good either... I'm confused, so is it possible to load data from several reporting entities in one rule to load or am I misreading the documentation?  Thank you in advance.

    Do not leave the field blank in the Import Format. If leave you empty to the place, when you set the rule to load data (for the location with EBS as a Source system), you will be able to select a single accounting entity or a group of accounting entity.

    You can see here

    Please mark this as useful or answer question so that others can see.

    Thank you

  • Map not finished execution, crashes on loading the data from the DB2 source

    Hello

    I created several direct mappings table = > DB2 in Oracle table. Basically, just move all the DB2 table in Oracle.
    After validation, build and deploy a mapping, I try to run it and what I've noticed, is that when the number of rows in the source table is small (up to 3000 lines) runs works without any problem. But when the number of rows is greater that that execution does not end and keeps hanging from point source JDBC.
    I check the process on the database (list_requests.sql) and the execution is there with availability information.
    Has anyone done this type of mapping? Can you please advise and help?
    Thank you and best regards,

    Leo

    Hello

    Worth a try to get the job by changing - setting mx128M in ccastart to see where it gets you and restart CSF. For example change - mx128M to-Xmx512M

    See you soon
    David

  • IrDA driver for Windows 7 on Acer laptop to be able to load the data from UWATEC Aladin Prime dive computer down

    I have a new Acer laptop with Windows 7.

    I have a new UWATEC Aladin Prime dive computer.

    I have instaled the SmartTRAK on the Acer softewair.

    I bought what I believe is an IrDA that plugs into the USB port says that it complies with RoHS standards. Notice on back indicates S/N: 090701165.

    I have been looking for a driver for the IrDA or find you a driver or if it'll work on the Acer laptop.

    I have technology obsolet?

    For any question on Windows 7:

    http://social.answers.Microsoft.com/forums/en-us/category/Windows7

    Link above is Windows 7 Forum for questions on Windows 7.

    Windows 7 questions should be directed to the it.

    You are in the Vista Forums.

    See you soon.

    Mick Murphy - Microsoft partner

  • Loading data from table to file odi.

    I need to load the data from the table to file without using the interface in odi.  How to do it.

    Hello

    using tool OdiSqlUnload, it loads the table directly.

    I tried the db oracle table to the file without using interfaces. I used with procedures.

    to achieve this, must create the procedure in odi. Select the control on the target technology: oditool.

    «OdiSqlUnload "-FILE = data procedure.txt D:\TEXT\Test" "-DRIVER = oracle.jdbc.OracleDriver" «-URL=jdbc:oracle:thin:@192.0.0.0:1521:odiuser ' '-USER = odiuser ""-PASS = hpfHiT7Ql0Hd79KUseSWYAVIA ""-FILE_FORMAT = VARIABLE ""-FIELD_SEP =, ""-ROW_SEP = \r\n ""-DATE_FORMAT = YYYY/MM/DD hh: mm: ""-CHARSET_ENCODING = ISO8859_1 "" "-XML_CHARSET_ENCODING = ISO-8859-1"»

    Select * from odiuser. DWT_SECTOR.

    I think this will help for you.

    Thnaks in advance,

    A.Kavya.

  • Is it possible to see/get the data from the table to a dump file

    I have files dmp generated using expdp on oracle 11 g...

    expdp_schemas_18MAY2013_1.dmp

    expdp_schemas_18MAY2013_2.dmp

    expdp_schemas_18MAY2013_3.dmp

    Can I use a settings file given below to get the data from the table in the file sql or impdp the only option to load the data of table in database.

    VI test1.par

    USERID = "/ as sysdba".

    DIRECTORY = DATA

    dumpfile=expdp_schemas_18MAY2013%S.dmp

    SCHEMAS = USER1, USER2

    LOGFILE = user_dump_data.log

    SQLFILE = user_dump_data. SQL

    and impdp parfile = test1.par.

    No,

    DataPump cannot retrieve a dumpfile data in a flat file.

    Dean

  • How to insert into a GLOBAL TEMPORARY TABLE and get the data from it?

    The requrement is
    Split the string ENTRY point on the base and store it in a Collection. And the values of the collection will be stored in a global temporary table. Then, I'm updating some other table based on the data from the temporary table.

    There is in fact no error message. But there is no data in the temporary table and also no change in the update statement

    First of all, I'm creatiing a global temporary table only once outside the procedure.

    CREATE GLOBAL TEMPORARY table GLt (data_element number)


    create or replace procedure test_proc (p_in_string VARCHAR2) is
    i the number: = 0;
    number of POS: = 0;
    CLOB lv_str: = p_in_string;
    p_delim VARCHAR2 (1): = ', ';

    TYPE t_array IS TABLE OF VARCHAR2 (20) INDEX directory.
    t_array channels;

    BEGIN

    -cutting of string input and store in the strings (i) collection

    POS: = instr (lv_str, p_delim, 1, 1);
    WHILE (pos! = 0) LOOP
    i: = i + 1;
    Strings (i): = substr(lv_str,1,pos-1);
    lv_str: = substr (lv_str, pos + 1, length (lv_str));
    POS: = instr (lv_str, p_delim, 1, 1);
    IF pos = 0 THEN
    Strings (i + 1): = lv_str;
    END IF;
    END LOOP;

    run immediately "drop table TWG;
    run immediately ' CREATE GLOBAL TEMPORARY table (data_element number) TWG on commit preserve rows ";

    FORALL i in strings.first... Strings.Last
    INSERT INTO VALUES TWG (strings (i));
    commit;

    Update first_tbl set PIN is "XXX" where first_col in (select data_element from TWG);.
    commit;

    END test_proc;

    Published by: cedric b on January 25, 2013 12:59

    Remove the two execute immediate line. They are wrong.

    And then use the table in your code that you created at the beginning. The name is GLT.
    And delete the first commit. This validation would empty the temporary table of GLT.

    You get an error? Or it does not work as expected?

    Also, show how you call the procedure.

    Published by: Sven w. January 25, 2013 14:45

  • Is mapping dimension AWM - possible to load the data in two tables of entry?

    Hi all

    I have two tables ProductFamily (parent level) and products (child level).

    I want to load a dimension of those tables where the parent-child relationships are maintained (I use AWM).

    I created a map with these two entry tables, but the loaded data has no relationship.
    So, how do I do that? Is it possible to load dimensions where different levels get data from multiple tables?
    Is any type of Carpenter available in AWM?

    Thank you

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

    A few Notes:

    -I don't want to use OWB here that my data are clean
    -In AWM, when I loaded the data in a single view that contains two tables of input data, it worked fine. But it's my worst case option.

    You must use Dimension option in snowflake in the mapping screen of size for the Product Dimension (as opposed to the default style mapping - star schema dimension).

    This will modify map entries to include a separate parent for each level of hierarchy level / that is to say, for each level of hierarchy / (unless a higher level of the hierarchy), you must specify the parent level key in addition to the key current level, code/name/description/other attributes etc.

    You can make the mapping or... use the icons at the top of the map screen.
    mode drag/drop by dragging the relational column on dimension - level/hierarchy/attribute model
    -or-
    the table expression mapping mode that gives the same effect... by dragging a column on an attribute defined in the .

    . the format of .

    HTH
    Shankar

    Note1: Complete the mapping of a sudden... B & w switching mapping modes cause the mappings to reset.
    NOTE2: assumes that your data are correct foreign key table parent level: ProductFamily exists in the child level table: products.

  • How to copy the data from the indicator table 1 d to the Clipboard

    Is it possible to copy data from table 1 d indicator to the Clipboard as a text and for more than one cell?

    I use LV8.6.

    Leszek

    Sorry, I wasn't sure if it was available in 8.6, apparently not.

    You could create an indicator of fine print and use 'picture to a worksheet string' to complete. Now, you can just cut & paste the text instead.

  • How to join two tables to retrieve the data from the columns in table two. Tables have primary and foreign key relationships

    Hello

    I want to join the two tables to retrieve the data from the columns of the two table passing parameters to the join query. Tables have primary and foreign key relationships

    Details of the table

    Alert-1 - AlertCode (FK), AlerID (PK)

    2 AlertCode-AlertDefinition-(PK)

    Help, please


    ----------

    Hi Vincent,.

    I think that you have not worked on adf 12.1.3.  In adf 12.1.3 you don't have to explicitly create the association. When you create the EO to your table, Association xxxxFkAssoc, will be created by ADF12.1.3 for you automatically. Please try this and do not answer anything... You can also follow the links below. I solved the problem by using the following link

    Oracle ADF Guide step by step - Oracle ADF tutorial: creating a relationship of the master / detail using Oracle ADF

    ---

Maybe you are looking for

  • Remote control does not work, and the load does not appear on Apple TV

    Hello I just returned from vacation and my remote seems has stopped working.   Naturally, my first assumption was that the charge was simply exhausted. Apparently that was the case.   He seems to have just died. I did pay for more than two hours and

  • need help to install El captain on iMac 2010 after secure hard disk format

    Hey guys... This might seem newb but the other day, I wiped firmly (format single-pass) my HARD drive on an imac 2010 with the Mavericks. Somehow the OS partition has been removed by the previous owner, but they didn't know how and gave me the system

  • Where to find the Starfield Screensaver

    original title; Starfield screensaver I am disappointed that Vista does not include the old Starfield screensaver.  Y at - it somewhere that I can get an original version of this screensaver, prefferably directly from Microsoft?

  • Blue screen of TouchPad

    TouchPad couldn't right star.  Showing the server error 'please visit http://hpwebos.com/support to help solve this problem. " When you choose close, blue display with "HP webOS on the left corner.  I can even tap and showing three options, "device i

  • My copy of windows is not genuine, apparently, and my product key contains an invalid character

    I use this computer for over a year with no problems, but when I started it today, my product key was apparently not valid. It contains either one I have either a 1, neither of which is a valid character. Is that what I can do about it?