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

Tags: Database

Similar Questions

  • while loading does no data in the table target, odi performance degrades?

    Hello

    I am trying to load some data from the source (Oracle DB1) to the target (Oracle, DB2) table in the same server

    Source table have 45lacks of data. These data must be load in the target table.

    I create interface. I took LKM SQL SQL & IKM SQL for SQL incremental Add.

    yesterday I executed interface, I checked the status in the browser of the operator. "his display like the loading status.

    However, the interface is in State of loading.

    sometimes odi is unresponsive. Plese help me.

    Need to add all the fetch sizes?

    Please solve this problem.

    Thank you and best regards,

    A.Kavya.

    Hello

    As you say, I tried with different knowledge modules. I used the incremental update IKM for db and db 45 do not data loading.

    its really increase performance. with in 10 minutes it will be correctly loaded into the target table. previously, I used SQL & SQL LKM, IKM SQL for SQL control append.it takes a long time. It takes two days also data is not loaded in the target table. really bad performance.

    I used DB loading for better performnace LKM SQL to ORACLE & IKM INCREMENTAL UPDATE.

  • How can I use notifications to send data from different sources for the same chart?

    Hello

    I use the model of 'Continuous measurement and logging' project comes with LV 2013.

    It is extremenly helpful in understanding the messaging between the acquisition, graphic and loops of newspaper. (Thank you NEITHER!)

    I ran into a snag though.

    I want to change so that my graphic loop receives notifications of data from two sources of acquisition by the declarant.

    I have trouble getting the data from the two sources to display on one graph.

    I've isolated the problem in the attached vi.

    Here's what happens:

    1. I create 2 parallel loops data and send the data to a third parallel loop with the notifiers.

    2. the third loop receives data from one of the loops because one of the authors of just receiving notifications is to expire instead of receive data.

    Can anyone suggest how can I fix?

    Thank you.

    -Matt

    Here's my modification of your VI. I put notes on the block diagram to explain the changes. He uses a queue for data transfer to avoid data loss. It uses a notifier to stop loops. All local variables and value property nodes have been eliminated.

    The way loops are arrested probably let some data in the queue. No more of one or two iterations of each of the loops of data acquisition. If you need ensure that all data has been displayed (or recorded in a real application), then you must stop acquiring loop first and read the queue until you know it's empty and both other loops stopped. Then stop the render loop and release the queue and the notifier.

    Lynn

  • Using the procedure to display the table of multiple data

    Hi, I need help for the procedure in oracle

    I want to create the procedure to display the table of multiples with sample plan

    with a parameter imployee_id to display an employee_id, name, function, start_date, end_date

    IAM using this query to select more than one table

    SELECT e.employee_id, e.first_name, j.job_title, h.start_date, h.end_date

    E EMPLOYEES

    JOIN j jobs

    ON j.job_id = e.job_id

    JOIN the job_history:

    ON h.employee_id = e.employee_id

    WHERE e.employee_id = 200;

    Thanks for the help

    Blu and Billy showed you the 'real' solution. You can display the data returned by a cursor ref in SQL Developer, too:

    http://www.thatjeffsmith.com/archive/2011/12/SQL-Developer-tip-viewing-refcursor-output/

    Yet as a duty for a beginner is generally do not have the expected solution. Usually, teachers want to see you using a LOOP and dbms_output. something like

    DECLARE

    Xy CURSOR IS

    SELECT whatever

    As much as;

    BEGIN

    FOR r IN xy LOOP

    dbms_output.put_line (r.col1 |' # ' | r.col2);

    END LOOP;

    END;

    Of course this suggestion will inaugurate a discussion abusing DBMS output but I keep my position that it is authorized to use it for learning the basics.

  • Could not load the dll target, the error code 126

    A "runner error" box keeps popping up saying "could not load the dll target, error 126" code.  This appears at all different times, even when I'm not using the computer.  I don't know why it gives me this error or how I can get rid of him for good.

    Hello Tracy,.

    Try to configure your system to boot into boot mode (Ref: http://support.microsoft.com/kb/310353) will help you identify the problem.

    I hope this helps.

  • How to migrate data from a source to multiple targets (tables)?

    How to migrate data from a source to multiple targets (tables)? Describe the General steps, please or point me to a tutorial

    Yes, a table in a mapping element can be source and target at the same time (i.e. a target can be reused as a source for the rest of the map on the right side of the table).

    Don't forget to check the order of loading (in the property map), to ensure that the reused as source is loaded before the final table target table.

    I tested it and it works. However, the documentation is not said in the link I gave you above:

    "Each element of data store that has entries but no exits in the logical diagram is considered a target."

    Usually, I tend not to do. I am in favour of a Divide and Conquer approach and try to have my mapping as simple as possible. It is easier to debug and maintain.

  • L50-A-19N satellite can not read audio data from multiple sources

    I can't read the audio data from multiple sources. It is very annoying when I have 2 youtube videos, playing, if I start playing something on the media player, there is no sound on media player, it's the same when I have 2 open media players and 1 youtube video playing, youtube video has no sound...
    It disappears when I plug my headphones...

    I already have all the latest drivers, the DTS driver was last updated was in 2014, his day of February of this year...






    25/02/14

    DTS Inc. Windows 8.1 - 64 Bit 1.01.2700

    I don't know if this has the feel, but I had his most recent DTS driver that I found, it is not my laptop model, but they all seem to be the same - v1.1.88.0
    I uninstalled the DTS software and still had the same problem, then it is irrelevant on its driver somehow...






    02/10/15

    Integrated Device Technology Inc. Windows 8.1 - 64 Bit 6.10.6491.0

    Audio driver IDT has more recent release date, but the version of the driver is the same as the 2013 one...
    Why the older drivers of toshiba releaseing as 'NEW '?

    2nd is my Advanced settings speakers, nothing has changed when I disabled "allow applications to take exclusive control of this device.

    Sorry but I don't understand your problem.
    I tested it on my machine and if I start the music on three different sources (YouTube, player, web radio) I can hear all together, but it makes no sense to listen to music from different sources.

    Or how do understand you?

  • I bought a new hard drive. I don't have a system recovery disk. Can I load Windows Vista from another source and activate using my original product key?

    I bought a new hard drive. I don't have a system recovery disk. Can I load Windows Vista from another source and activate using my original product key?

    Hello

    There is no download available from Microsoft Vista.

    Contact the manufacturer of your laptop and ask them to send a set of recovery disks.

    They should do this for a small fee.

    "How to replace Microsoft software or hardware, order service packs and replace product manuals.

    http://support.Microsoft.com/kb/326246

    Some manufacturers have more available Vista recovery disks.

    If this happens, you may need to try this instead:

    You can also borrow and use a Microsoft Vista DVD, which contains the files for the different editions of Vista (Home Basic, Home Premium, Business and Ultimate) must be installed. The product key determines which Edition is installed.

    Builders recovery DVDs are should not be used for this purpose.

    And you need to know the version of 'bit' for Vista, as 32-bit and 64-bit editions come on different DVDs

    See you soon.

    p.s. If the old hard drive is still installed and running before you change on hard drives and you never received the to purchase recovery discs, you can make the recovery discs from the recovery Partition which should be on the old hard drive. You will need to request that the manufacturer how to do as each computer manufacturer has their own way of making records of this partition recovery.

    It depends on the old hard drive still works.

  • Need to load fresh data from the OLTP system DAC

    Hi gurus,

    I'm new to DAC and with little knowledge, I believe I messed up things. I had to make in the data in the timestamp column for that reason changed the type of data in the column of timestamp date, that I need to load the historial data also. I had gone DAC and made a full charge. But there is no a couple of times.

    During the last failed one of the WF charge as DAC failed to create an INDEX ON a table as he had duplicate rows, I had to remove scripts the duplicate records and headed again.

    But now, in one of my dashboard, the columns are empty.

    My Question: As this is a system of UAT, I want everything clean and load all over again as it would be for a first load of time. I mean full charge but it fails. Is there any process in DAC where he loads new data delete all data in the existing system of data warehouse so that there is no shortage and I get all the data.

    Thank you

    Amit

    Go to tools-> management-> Reset Data Sources ETL

    For the next execution it will truncate any existing data and start loading the first because it will be a full load of the CBC to tgt

    mark, if this can help

    Please post you spend here for upcoming posts: https://forums.oracle.com/community/developer/english/business_intelligence/business_intelligence_applications/business_intelligence_applications_2/content

  • SQL query in mapping to load the table from the warehouse

    Hi experts,

    I hope you can help me solve my problem. I already tried here in the forum how we can add a query in a mapping, but still not found the answer.
    In my store, I have a time dimension table that has a unique dimension key and all the date information. In my source database, I have a table for business information. In this dirty table, I have a field named date. This date will be in exact format.
    I also have a table sales in my warehouse which is almost a copy of the sales table from the source. I don't have that one more field in this table sale warehouse called "time_dim_key". This field should get the key of the dimension of the time dimension table warehouse based on the date of the sales table of source.
    Do I think a mapping, which includes:
    -the table sales source
    -the time of warehouse dimension table
    -the table of sales warehouse
    Normal fields can I directly table card sales from source to sale warehouse table.
    But the 'time_dim_key' of the table field dirty warehouse should fill up as:
    Select dimension_key in the warehouse_time_dim_table where day_date = source_sales_table.date
    Unfortunately I do not know how to include a query to get the exact date of this sale of source table in the mapping to fill the sales table from the warehouse.
    I hope someone can help me solve this issue.

    Thank you very much!
    Kind regards
    David

    take the Carpenter of the palette
    and create two groups
    1.warehouse_time_dim_table
    2.source_sales_table

    then, write the join condition,
    warehouse_time_dim_table.day_date = source_sales_table.date

    Who will solve the purpose.

    See you soon
    Katia

  • How to load the file name in the table target. ?

    Hi Expertise,

    I load the data of 100 files of same schema using packages,

    It is a variable stores the names of files. I used this link for reference: ODI gurus: SEVERAL FILES - TARGET SINGLE TABLE - SINGLE INTERFACE & several files simple single interface target .

    but now I need what files have been executed in the interface. Please give me some ideas?
    I need when the data from a particular file was loading then in DB, the particular file name must also be sent to the target.

    using ODI 11.1.1.9 & wls 10.3

    Help with kindness,

    Thank you

    Shakur

    In my example src_file_name is a column name

    and #projectName.variableName - is a variable

    If you want to store in the column you define '#projectName.variableName.txt '- don't forget the single quotes - (as a result, you get an error)

  • Mapping of 12 ODI is a failure loading the table to the table in oracle DB

    Hi Experts,

    I'm starting to ODI, attempts to load data from the Table to the Table in Oracle DB. Source table and target table are in the same PB in different schema

    I created my own work, also agent and master repository.

    Started with the agent, and I could see the status as Planner started for referential work * on Agent OracleDIAgent1.

    Created the agent in topology and successfully tested.

    Created data and connections physical schema of the source and target servers, Test connection is successful.

    Created the context and logical schema defined for the source and the target.

    Mapped to the corresponding physical schema context.

    Diagram logical and physical mapping is accomplished in the context.

    Created for source and target models, able to view the data in the source model.

    Created a simple map and put in source and target component context.

    LKM selected as LKM SQL for SQL

    Select IKM as IKM Oracle Insert.GLOBAL

    After execution, the mapping is a failure with the error below

    Drop table work - LKM SQL for SQL

    ODI-1222: start failure on agent edge internal: logical schema * is not found in the main repository.

    Create the table work - LKM SQL for SQL

    ODI-1222: start failure on agent edge internal: logical schema * is not found in the main repository.

    ODI-1222: start failure on agent edge internal: logical schema * is not found in the main repository.

    at oracle.odi.runtime.agent.execution.AbstractSessionTask.getSrcDataServer(AbstractSessionTask.java:1646)

    at oracle.odi.runtime.agent.execution.interpreter.SessionTaskCodeInterpreter.codeInterpretation(SessionTaskCodeInterpreter.java:132)

    at oracle.odi.runtime.agent.execution.interpreter.SessionTaskCodeInterpreter.codeInterpretation(SessionTaskCodeInterpreter.java:80)

    at oracle.odi.runtime.agent.execution.SessionTask.createTaskLog(SessionTask.java:324)

    at oracle.odi.runtime.agent.execution.AbstractSessionTask.execute(AbstractSessionTask.java:821)

    to oracle.odi.runtime.agent.execution.SessionExecutor$ SerialTrain.runTasks (SessionExecutor.java:2024)

    at oracle.odi.runtime.agent.execution.SessionExecutor.executeSession(SessionExecutor.java:562)

    to oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor$ 1.doAction(TaskExecutorAgentRequestProcessor.java:718)

    to oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor$ 1.doAction(TaskExecutorAgentRequestProcessor.java:611)

    at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:203)

    at oracle.odi.runtime.agent.processor.TaskExecutorAgentRequestProcessor.doProcessStartAgentTask(TaskExecutorAgentRequestProcessor.java:800)

    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$ 1400 (StartSessRequestProcessor.java:74)

    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ StartSessTask.doExecute (StartSessRequestProcessor.java:702)

    at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:180)

    to oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$ 2.run(DefaultAgentTaskExecutor.java:108)

    at java.lang.Thread.run(Thread.java:722)

    Please help me with the problem above,

    Thanks in advance.

    Kind regards

    Srikanth

    Hi Srikanth,

    It is usually better to create a separate scheme for the scheme of work, but you can keep the data and schema of work even. Also in your error log, the error should now be to the right of the IKM? No LKM. Try changing the logical schema name and see if it works.

    Thank you

    Ajay

  • Stored procedure to create the table .csv file

    Hi all
    I have a table with 4 columns and 10 rows. Now I need a stored procedure to create a file .csv from the data in the table. Here the script to create a table and insert the line.

    Create table emp (emp_id number (10), emp_name varchar2 (20), Department varchar2 (20), number (10)) of salary;

    Insert into emp values ('1', 'AAAAA', '' SALES, 10000');
    Insert into emp values ('2', 'BATH', 'MARKETING', '8000');
    Insert into emp values ('3', 'CCCCC', '' SALES, 12000');
    Insert into emp values ('4', 'JAMES', 'FINANCE', '10000');
    Insert into emp values ('5', 'EEEEE', '' SALES, 11000');
    Insert into emp values ('6', 'FIRE', 'MANAGER', '90000');
    Insert into emp values ('7', 'GEORGE', '' SALES, 12000');
    Insert into emp values ('8', 'HAROLD', 'FINANCE', '14000');
    Insert into emp values ('9', 'IIIII', '' SALES, 20000');
    Insert into emp values ('10', 'GG', 'FINANCE', '21000');
    commit;

    Now I need a stored procedure to create a .csv file in my local location. Please let me know if you need more details...

    A few tips:
    http://www.Oracle-base.com/articles/9i/GeneratingCSVFiles.php
    http://tkyte.blogspot.com/2009/10/httpasktomoraclecomtkyteflat.html
    also, doing a search on this forum or http://asktom.oracle.com will give you many clues.

    in my local location .csv file.

    What is your "local position"?
    A client machine? The database server machine?
    Which version of the database you use?
    (the result of: select * version of $ v ;))

  • call sub procedure for updating the table - need help

    Hi all

    I have a scneario wherein I get three values 0,2.5 and 57.
    For each value, I'll call another procedure that updates a table "sample_dest".
    The "sample_dest" table has a column "dest_nbr."

    Now, for each three values I get,
    I want to update only one record in the table 'sample_dest '.

    for example, I want to update the column "dest_nbr" with a value of 59.5 (0 + 2.5 + 57).

    I am unable to do this, because every time the procedure is called,
    the previous values are not stored. 57 is the last value I get,
    I am able to store only 57. But I want 59.5 to be updated in the table.

    How can I achieve this.
    Help, please.

    Concerning
    Rambeau.

    This should be done in a single sql statement, not in a loop of cursor (which is what it looks like you're doing). If sample_desc already contains records for samples, so it should look like:

    UPDATE sample_desc sdesc
    SET desc = (SELECT AVG(code) FROM sample_dest sdest
                WHERE sdesc.sample = sdest.sample)
    WHERE EXISTS (SELECT 1 FROM sample_dest sdest
                  WHERE sdesc.sample = sdest.sample)
    

    If sample_desc does not already contain records (unknown from your description), then it would be an insert as:

    INSERT INTO sample_desc
    SELECT sample, AVG(code)
    FROM sample_dest sdest
    GROUP BY sample
    

    John

  • How to load the table to pick up equity?

    I am plans to use the routine void Equity Pickup(), but can not find information on how to charge the owner, property, details UPR %? Any help or sample file is appreciated.

    Yes. Once loaded, you will be able to view the table to manage equity Pick Up. We thought it useful that the percentages are loaded every month, so we don't have to maintain a hierarchy of entity metadata and history of changes with the change of ownership.

Maybe you are looking for

  • Intel VT Linux on Tecra M5-402

    Hello I own a laptop Tecra M5-402 (Core 2 T7200, 2 GB of Ram, NVS 110). I enabled Intel VT in the BIOS (really the BIOS, stripped windows that were placed above it no longer exists on my hard drive, like Win XP pro) and my home Linux kernel 2.6.23.1

  • terminals connected to various types

    Hello This error but they are the same two data type? _____________________________________________________ These can be wired together as their data types (digital, string, array, cluster, etc.) do not match. View the contextual help window to find

  • The Windows Installer service could not access while trying to install Skype

    They advised me to contact my support staff to verify that Windows Installer service is properly registered.  I don't know which is referenced support staff.  Help, please.

  • The Media Center for Windows 7 free download

    My media center disappeared, where can I download it? Please, help me.

  • CalendarEvent and zones

    I have a problem to find the right way to create a CalendarEvent in another time zone on my Z10 my timezone is: Amsterdam, Berlin + 1 (THIS/MEZ == UTC + 1) seems that Z10 uses only the standard time here and not the time of daylight, but the clock is