Insert data into multiple tables

Hi all,
I've a requirement where i need to insert data into multiple tables using PL/SQL procedure
Procedure should have two parameters
1. Table Name (parameter1)
2. Data (parameter2)
Based on these two parameters i need to insert data into table (parameter1) using data (parameter2)
ex:
Procedure insert_data (p_table  IN VARCHAR2
                      ,p_data   IN -- what should be the datatype?
IS
l_statement VARCHAR2(2000);
BEGIN
-- insert data into tables
INSERT INTO p_table
values (....);
END insert_data;Thanks in advance!!

BEDE wrote:
Amen to that!
So, I believe a better approach would be the following...
Suppose you have N datafiles with the same structure, and you wish to insert into the database the data from all those files.
For that, you should have a single table, named, say incoming_file_data, which should be structured more or less like below:
create table incoming_file_data (
filename varchar2(250) not null -- name of the file inserted from
,file_time timestamp -- timestamp when the data was inserted
,... -- the columns of meaningful data contained in the lines of those files
);And you will insert the data from all those files in this table, having normally one transaction for each file processed, for otherwise, when shit happens, some file may only get to be partially inserted into the table...
Maybe one good approach would be to create dynamically an external table for the file to be loaded, and then execute dynamically insert select into the table I said, so that you will have only one insert select for one file instead of using utl_file... RTM on that.If the file structures are the same, and it's just the filename that's changing, I would have a single external table definition, and use the alter table ... location ... statement (through execute immediate) to change the filename(s) as appropriate before querying the data. Of course that's not scalable if there are multiple users intenting to use this, but generally when we talk about importing multiple files, it's a one-user/one-off/once-a-day type of scenario, so multi-user isn't a consideration.

Similar Messages

  • Inserting data into multiple tables in jdbc

    I am doing on file to jdbc. Now I got a requirement to insert data into multiple tables on the receiver side. How can I do this ?

    Hi,
    you are going to insert data into 4 tables in a sequence one after another , I see three options.
    1) Stored procedure and 2) creating 4 statement data structure (one for each table)
    The third option is writing a SQL with join for the 4 tables and use action command = SQL_DML. Example as follows....
    Write SQL code and place it in access tag. Pass values for the columns using key tag...
    <stmt>
        <Customers action="SQL_DML">
          <access> UPDATE Customers SET CompanyName=u2019$NAME$u2019, Address=u2019$ADDRESS$' WHERE CustomerID='$KEYFIELD$u2019
          </access>
          <key>
            <NAME>name</NAME>
            <ADDRESS>add </ADDRESS>
            <KEYFIELD>1</KEYFIELD>
          </key>
        </Customers>
      </stmt>
    Refer this http://help.sap.com/saphelp_nwpi71/helpdata/en/44/7b7855fde93673e10000000a114a6b/content.htm
    Hope this helps ....

  • Inserting data into multiple tables(Oracle Version 9.2.0.6)

    Hi,
    we are going to receive the following XML file from one of our vendor. We need to parse the file and then save the data to multiple database tables (around 3).
    <?xml version="1.0"?>
    <datafeed xmlns:xsi="ht tp://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DailyFeed.xsd" deliverydate="2007-02-14T00:00:00" vendorid="4">
    <items count="1">
    <item feed_id="001379" mode="MERGE">
    <content empbased="true">
    <emp>10000000</emp>
    <value>
    </value>
    <date>2006-01-16</date>
    <unit>CHF</unit>
    <links>
    <link lang="EN">
    <url>www.pqr.com</url>
    <description>pqr website</description>
    </link>
    <link lang="DE">
    <url>www.efg.com</url>
    <description>efg website</description>
    </link>
    </links>
    </content>
    <content empbased="true">
    <emp>10000001</emp>
    <value>
    </value>
    <date>2006-01-16</date>
    <unit>CHF</unit>
    <links>
    <link lang="EN">
    <url>www.abc.com</url>
    <description>abc website</description>
    </link>
    <link lang="DE">
    <url>www.xyz.com</url>
    <description>xyz website</description>
    </link>
    </links>
    </content>
    <content empbased="true">
    <emp>10000002</emp>
    <value>
    </value>
    <date>2006-01-16</date>
    <unit>CHF</unit>
    <links>
    <link lang="IT">
    <url>www.rst.com</url>
    <description>rst website</description>
    </link>
    </links>
    </content>
    </item>
    </items>
    </datafeed>
    Now the operation to be done on the table depends on the mode attribute. Further, there are some basic validations need to be done using count attribute. Here the item tag, content tag & link tag are recurring elements.
    The problem is I am not able to find the correct attributes like mode, feed_id, lang through SQL query(they are getting duplicated) though I was able to find the deliverydate & vendorid attribute as they are non-repeatitive. Here are the scripts :
    create table tbl_xml_rawdata (xml_content xmltype);
    create directory xmldir as 'c:\xml';
    --put the above xml file in this directory and name it testfile.xml
    Declare
    l_bfile BFILE;
    l_clob CLOB;
    BEGIN
    l_bfile := BFileName('XMLDIR', 'testfile.xml');
    dbms_lob.createtemporary(l_clob, cache=>FALSE);
    dbms_lob.open(l_bfile, dbms_lob.lob_readonly);
    dbms_lob.loadFromFile(dest_lob => l_clob,
    src_lob => l_bfile,
    amount => dbms_lob.getLength(l_bfile));
    dbms_lob.close(l_bfile);
    insert into test_xml_rawdata values(xmltype.createxml(l_clob));
    commit;
    end;
    My query is:
    select extractvalue(value(b),'/datafeed/@deliverydate') ddate, extractvalue(value(b),'/datafeed/@vendorid') vendorid,
    extractvalue( value( c ), '//@feed_id') feed_id,
    extractvalue( value( a ), '//@empbased') empbased,
    extractvalue( value( a ), '//emp') emp,
    extractvalue( value( a ), '//value') value,
    extractvalue( value( a ), '//unit') unit,
    extractvalue( value( a ), '//date') ddate1,
    extract( value( a ), '//links/link/url') url,
    extract( value( a ), '//links/link/description') description
    from tbl_xml_rawdata t,
    table(xmlsequence(extract(t.xml_content,'/datafeed/items/item/content'))) a,
    table(xmlsequence(extract(t.xml_content,'/'))) b ,
    table(xmlsequence(extract(t.xml_content,'/datafeed/items/item'))) c;
    If the above query is run, the feed_id is cartesian joined with other data ,which is wrong.
    How should I go with this so that I can have 1 relational record with respect to each element & sub-elements.
    Also, if this is not doable in SQL, can someone direct me to some plsql example to do this. I read that dbms_xmldom & dbms_xmlparser can be used to travel through XML doc but I don't know how to use them.
    Any help please ??

    I'm still getting the same error while installing Oracle Patch set 9.2.0.6. I downloaded the patchset 2 weeks back.
    Pls help where download the correct version ?

  • Inserting data into multiple tables(on DB).

    Hi,
    I have 2 tables in DB.
    Person{ID, Name,Surname}
    Address{city,street,tel.zip}
    Where both of them are entity classes.
    I want to insert data from one jsp page
    I tried it but i got error :
    javax.servlet.ServletException: Target Unreachable, 'address' returned null
    I need some hints.
    Thank you.

    My DB is located on Derby,
    I am trying to reach from jsp pages. Like NewPerson.jsp from wich i want to create new person and his address.
    It can see person bean but can not reach address bean.
    Thanx.

  • I need to insert data into multiple tables - how?

    Using ASP, VBScript & MS SQL -
    My main table has a PK with the name projectID, this field is
    updated automatically in SQL. I need that ID in order to populate
    the rest of the tables. How do I retrieve this ID before moving on
    to the next page(s)?
    I've seen some similar questions but none have really been
    answered, Hoping this time is the charm.
    Thanks

    Post your SQL statements and I will put this into a Stored
    Procedure for
    you. This will give you far more flexibility and will run
    more efficiently.
    I may not be able to do it tonight though as I am about to go
    out.
    "Mark.P." <[email protected]> wrote in message
    news:[email protected]...
    >I do have that option but I don't know how to write them.
    I don' t
    >normally do
    > this kind of thing but due to recent org changes i'm
    learning on the fly.
    > I
    > was hoping this would be on the easy side. Guess not (at
    least not for
    > me).
    > Here's where I'm at now with it, it's returning an error
    at this point.
    >
    >
    >
    >
    > <%
    > If (CStr(Request("MM_insert")) = "addProject") Then
    > If (Not MM_abortEdit) Then
    >
    > 'intNewKeyVal = rsProjects.Execute(MM_editCmd,
    intRecordsAffected,
    > adCmdText)(0)
    > ' execute the insert
    > Dim MM_editCmd
    >
    > Set MM_editCmd = Server.CreateObject ("ADODB.Command")
    > MM_editCmd.ActiveConnection = MM_commStr_STRING
    > MM_editCmd.CommandText = "INSERT INTO dbo.projects
    (pName, pLead,
    > status,
    > startDate, endDate, audience, ojective, deliverables,
    issues) VALUES (?,
    > ?, ?,
    > ?, ?, ?, ?, ?, ?) SELECT SCOPE_IDENTITY()"
    > MM_editCmd.Prepared = true
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param1", 202,
    > 1,
    > 100, Request.Form("pName")) ' adVarWChar
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param2", 202,
    > 1,
    > 100, Request.Form("pLead")) ' adVarWChar
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param3", 202,
    > 1,
    > 50, Request.Form("status")) ' adVarWChar
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param4", 135,
    > 1,
    > -1, MM_IIF(Request.Form("startDate"),
    Request.Form("startDate"), null)) '
    > adDBTimeStamp
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param5", 135,
    > 1,
    > -1, MM_IIF(Request.Form("endDate"),
    Request.Form("endDate"), null)) '
    > adDBTimeStamp
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param6", 202,
    > 1,
    > 250, Request.Form("audience")) ' adVarWChar
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param7", 202,
    > 1,
    > 500, Request.Form("objective")) ' adVarWChar
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param8", 202,
    > 1,
    > 500, Request.Form("deliverables")) ' adVarWChar
    > MM_editCmd.Parameters.Append
    MM_editCmd.CreateParameter("param9", 202,
    > 1,
    > 500, Request.Form("issues")) ' adVarWChar
    > MM_editCmd.Execute
    > intNewKeyVal = rsProjects.Execute(MM_editCmd,
    intRecordsAffected,
    > adCmdText)(0)
    > MM_editCmd.ActiveConnection.Close
    >
    > ' append the query string to the redirect URL
    > Dim MM_editRedirectUrl
    > MM_editRedirectUrl = "insertPart2.asp?fKey=intNewKeyVal"
    > If (Request.QueryString <> "") Then
    > If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) =
    0) Then
    > MM_editRedirectUrl = MM_editRedirectUrl & "?" &
    > Request.QueryString
    > Else
    > MM_editRedirectUrl = MM_editRedirectUrl & "&"
    > Request.QueryString
    > End If
    > End If
    > Response.Redirect(MM_editRedirectUrl)
    > End If
    > End If
    > %>
    >

  • How to insert one table data into multiple tables by using procedure?

    How to insert one table data into multiple tables by using procedure?

    Below is the simple procedure. Try the below
    CREATE OR REPLACE PROCEDURE test_proc
    AS
    BEGIN
    INSERT ALL
      INTO emp_test1
      INTO emp_test2
      SELECT * FROM emp;
    END;
    If you want more examples you can refer below link
    multi-table inserts in oracle 9i
    Message was edited by: 000000

  • How to insert data into a table only when data has changed its value (when compared to the previous inserted value)

    I wish to insert data into a table only when the value of the inserted data has changed. Thus, in a time series, if the value of the data at time, t-1, is 206 then if the data to be inserted at time t is 206, then it is skipped (not entered).
    If the value of the data at time t+1 is 206, it is skipped also; until the value changes, so if the value at t+1 was 205, then that would be inserted, and if at time t+2 the data is 206, it would be inserted too.
    What is the best way to do it without increasing overheads?

    This view works:
    SELECT
    i.IDNO,i.[Date],i.[Level]
    FROM
    mytable i
    INNER
    JOIN mytable
    d
    ON
    d.IDNO
    = i.IDNO-1
    WHERE
    i.[Level]
    <> d.[Level]
    on this mytable below.  A trigger could be quite useful here although I am cautious using them. However I wish to avoid the overhead by not having a temp table (which could be sizable).  mytable below
    should give 3 lines. The IDNO is an identity column.
    IDNO
    Item
    Date
    Level
    1
    X24
    12/23/13 10:41
    22996
    2
    X24
    12/23/13 10:41
    22996
    3
    X24
    12/23/13 9:21
    23256
    4
    X24
    12/23/13 9:21
    23256
    5
    X24
    12/23/13 9:22
    23256
    6
    X24
    12/23/13 9:22
    23256
    7
    X24
    12/23/13 9:22
    22916

  • How to insert data into a table from an xml document

    using the XmlSql Utility, how do I insert data into a table from an xml document, using the sqlplus prompt.
    if i use the xmlgen.insertXML(....)
    requires a CLOB file, which i dont have, only the xml doc.
    Cant i insert directly from the doc to the table?
    the xmlgen examples I have seen first convert a table to a CLOB xmlString and then insert it into another table.
    Isnt there any other way?

    Your question is little perplexing.
    If you're using XML SQL Utility from
    the commandline, just use putXML.
    java OracleXML putXML
    null

  • In ADF how can i insert data in multiple table if they have foreign key

    I have started working on ADF and can anybody inform me in ADF how can i insert data in multiple table if they have foreign key,please?
    Thnak you very much.

    Hello,
    Still no luck.I am surely doing silly mistakes.Anyway,Here are my workings-
    1> student_mst (id(pk),studentname) and student_guard_mst(id(fk),guardianname)
    2> created EO from both of the tables,made id in both EO as DBSequence and an association was also generated.
    3> i made that association composite by clicking the checkbox
    4> i created 2 VO from 2 EO.
    5> put those VO in Application Module.
    6> dragged and dropped 2 VO on my jspx page and dropped them as ADF Form.
    Now what to do please?

  • Insert data into multiple entities at once using a view object

    Hi,
    I'm trying to insert data into multiple entities at once using a view object, but unfortunately it doesn't seem to work. The two entities have a 1:1 association. I created a view object which contains both entities and I made sure they aren't read-only. But like I said it doesn't work, I can't insert data in both entities at once... :(
    Is this possible? And how (if it is)?

    Hi,
    I'm trying to insert data into multiple entities at once using a view object, but unfortunately it doesn't seem to work. The two entities have a 1:1 association. I created a view object which contains both entities and I made sure they aren't read-only. But like I said it doesn't work, I can't insert data in both entities at once... :(
    Is this possible? And how (if it is)? Peter:
    This is definitely supported and tested. Please send us the exception stack trace. You must running into other problems. A few things to note:
    A) You have to mark the entities as both updateable (not read-only) and not reference-only.
    B) If you're not seeing an exception stack, turn on diagnostic. Here is how:
    To turn on diagnostic, go to the IDE,
    1. Select the project.
    2. Do right mouse click and select "Project Settings..."
    3. On the Settings dialog, select Configurations/Runner.
    4. In the righthand side pane, you should see a textbox for "Java
    Options". Please add the following JVM switch:
    -Djbo.debugoutput=console
    Then, rerun. The run command should include
    -Djbo.debugoutput=console as in
    "D:\JDev9i\jdk\bin\javaw.exe" -Djbo.debugoutput=console -classpath ...
    You should now see a lot more output on the IDE's message window. Here you should see the exception stack trace.
    If you invoking your app directly from command prompt, just add "-Djbo.debugoutput=console" after your "java.exe".
    Thanks.
    Sung

  • Inserting Data into nested table

    I am exploring the differences between OBJECT & RECORD.
    As i am still in process of learning, I found that both are structures which basically groups elements of different datatypes or columns of different datatypes, one is used in SQL and other is used in PL/SQL, please correct me if I am wrong in my understanding.
    Below i am trying to insert data into an table of type object but i am unsuccessful can you please help.
    CREATE OR REPLACE type sam as OBJECT
    v1 NUMBER,
    v2 VARCHAR2(20 CHAR)
    ---Nested Table---
    create or replace type t_sam as table of sam;
    --Inserting data----
    insert into table(t_sam) values(sam(10,'Dsouza'));
    Error Message:
    Error starting at line 22 in command:
    insert into table(t_sam) values(sam(10,'Dsouza'))
    Error at Command Line:22 Column:13
    Error report:
    SQL Error: ORA-00903: invalid table name
    00903. 00000 -  "invalid table name"
    *Cause:   
    *Action:

    Ariean wrote:
    So only purpose of equivalent SQL types concept of nested tables is to use them as one of the data types while defining an actual table?
    Sort of - you can definitely use them for more than just "defining an actual table". (I'm fairly certain you could pass a nested table into a procedure, for example - try it, though - I'm not 100% sure on that - it just "makes sense". If you can define a type, you can use it, pass it around, whatever.).
    Ariean wrote:
    And that nested table could be a record in SQL or an Object in PLSQL or just simple datatype(number,varchar etc)?
    Nested tables are just like any other custom data type. You can create a nested table of other data types. You can create a custom data type of nested tables.
    It could get stupidly .. er, stupid O_0
    CREATE TYPE o_myobj1 AS object ( id1   number, cdate1  date );
    CREATE TYPE t_mytype1 AS table of o_myobj1;
    CREATE TYPE o_myobj2 AS object ( id2   number,  dumb  t_mytype1 );
    CREATE TYPE t_dumber AS table of o_myobj2;
    O_0
    Ok, my brain's starting to hurt - I hope you get the idea
    Ariean wrote:
    Secondly is my understanding correct about OBJECT & RECORD?
    I can't think of any benefit of describing it another way.

  • How do I run a database procedure that inserts data into a table from withi

    How do I run a database procedure that inserts data into a table from within a Crystal report?
    I'm using CR 2008 with an Oracle 10i database containing a number of database tables, procedures and packages that provide the data for the reports I'm developing for my department.  However, I'd like to know when a particular report is run and by whom.  To do this I have created a database table called Report_Log and an associated procedure called prc_Insert_Entry that inserts a new line in the table each time it's called.  The procedure has 2 imput parameters (Report_Name & Username), the report name is just text and I'd like the username to be the account name of the person logged onto the PC.  How can I call this procedure from within a report when it's run and provide it with the 2 parameters?  I know the procedure works, I just can't figure out how to call it from with a report.
    I'd be grateful for any help.
    Colin

    Hi Colin, 
    Just so I'm clear about what you want: 
    You have a Stored procedure in your report.  When the report runs, you want that same procedure to write to a table called Report_Log. 
    If this is what you want the simple answer is cannot be done.  Crystal's fundamental prupose is to read only, not write.  That being said, there are ways around this. 
    One way is to have a trigger in your database that updates the Report_Log table when the Stored Procedure is executed.  This would be the most efficient.
    The other way would be to have an application run the report and manage the entry. 
    Good luck,
    Brian

  • Error while inserting data into a table.

    Hi All,
      I created a table.While inserting data into the table i am getting an error.Its telling "Create data Processing Function Module".Can any one help me regarding this?
    Thanx in advance
    anirudh

    Hi Anirudh,
      Seems there is already an entry in the Table with the same Primary Key.
    INSERT Statement will give short dump if you try to insert data with same key.
    Why dont you use MODIFY statement to achieve the same.
    Reward points if this Helps.
    Manish

  • Its very urgent:how to insert data into database tables

    Hi All,
    I am very new to oaf.
    I have one requirement data insert into database tables.
    here createPG having data that data insert into one custom table.
    but i dont know how to insert data into database tables.
    i wrote the code in am,co as follows.
    in am i wrote the code:
    public void NewoperationManagerLogic()
    ManagerCustomTableVOImpl vo1=getManagerCustomTableVO1();
    OADBTransaction oadbt=getOADBTransaction();
    if(!vo1.isPreparedForExecution())
    vo1.executeQuery();
    Row row=vo1.createRow();
    vo1.insertRow(row);
    in createPG processrequest co:
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
    am.NewoperationManagerLogic();
    process form request:
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    if(pageContext.getParameter("Submit")!=null)
    ManagerInformationAMImpl am=(ManagerInformationAMImpl)pageContext.getApplicationModule(webBean);
    am.getOADBTransaction().commit();
    please help with an example(sample code).
    its very urgent.
    thanks in advance
    Seshu
    Edited by: its urgent on Dec 25, 2011 9:31 PM

    Hi ,
    1.)You must have to create a EO based on custom table and then VO based on this EO eventually to save the values in DB
    2.) the row.setNewRowState(Row.STATUS_INITIALIZED); is used to set the the status of row as inialized ,this is must required.
    3.) When u will create the VO based on EO the viewattributes will be created in VO which will be assigned to the fields to take care the db handling .
    You must go thtough the lab excercise shipped with you Jdeveloper ,there is a example of Create Employee page ,that will solve your number of doubts.
    Thanks
    Pratap

  • Insert data into nested tables

    Hi,
    Can someone please advice how can I insert data into nested tables using APEX.
    I have a table "employee" and a column addresses of type address_table_type object which has address1, address2, address3 columns. I want to create form in APEX that will collect address1, address2, address3. I wonder how to do this? should the item be based in database item? if yes then how can I point to the column of address_table_type
    Thanks
    --Aali                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Can you post your tabB type, sample data, and your exact insert statement?
    Is it overwriting or not commiting the inserts?
    Have you traced your session to see what is happening?

Maybe you are looking for

  • Nota Fiscal Eletrônica de Importação

    Pessoal, Estamos implantando a NFe no cliente que possui processo de importação, porém, estamos com dificuldades no seguinte problema: Para os casos que a empresa realizar uma importação onde a emissão da Nota Fiscal seja no último dia do mês, a merc

  • How do you get your contacts moved over to your iphone4?

    i just got my new iphone 4 and i had a droid 2 before i cant seem to get my contacts moved over. so is there a easy way to get them on there?

  • How To connect More Then One database

    How To Connect More the One Database In Single form. I want to use Access And Oracle In the Same Form. I want to Transfer data from Access file To oracle database. Chirag

  • JDeveloper Updates for 10.1.2.1.0

    I am trying to check updates for Spring Framework. When I try to connect I get the following error. "An error occured while getting updates from OTN. This maybe due to a network problem, proxy settings or the update center may be temporarily availabl

  • Photoshop Elements 10 Organizer incomprehensible

    I suppose this isn't a good question,but I find the so-called organizer in elements 10 impossible to understand and use. I use the Macintosh version. I don't get the point of it, whereas the Adobe Bridge in my previous version of elements was clear a