Need to insert rows into 100 tables at a time

hi there,
below is our script for creation of 100 tables...
we need a plsql script, to insert rows into 100 tables at a single time...
please help us...vey urgent...
DECLARE
counter NUMBER;
sql_string VARCHAR2(2000);
BEGIN FOR counter IN 1..100 LOOP sql_string := 'CREATE TABLE emp_table'||counter||'
(id integer primary key, col_a VARCHAR2(42),col_b date,col_c number,col_d varchar2(20),col_e varchar2(20),
col_f varchar2(20),col_g varchar2(20),col_h date,col_i varchar2(20),col_j varchar2(20),col_k date)';
EXECUTE IMMEDIATE sql_string;
END LOOP;
END;
/

hi,
below is our procedure and the error we are getting...
Name Null? Type
ID VARCHAR2(10)
COL_A VARCHAR2(10)
COL_B VARCHAR2(10)
COL_C VARCHAR2(10)
COL_D VARCHAR2(10)
COL_E VARCHAR2(10)
COL_F VARCHAR2(10)
COL_G VARCHAR2(10)
COL_H VARCHAR2(10)
COL_J DATE
DECLARE
counter NUMBER;
sql_string VARCHAR2(4000);
BEGIN FOR counter IN 1..100 LOOP sql_string := 'CREATE TABLE emp_a'||counter||'
(id varchar2(10), col_a varchar2(10), col_b varchar2(10), col_c varchar2(10), col_d varchar2(10), col_e varchar2(10),
col_f varchar2(10), col_g varchar2(10), col_h varchar2(10), col_j date)';
EXECUTE IMMEDIATE sql_string;
END LOOP;
END;
DECLARE
counter NUMBER;
sql_string VARCHAR2 (2000);
BEGIN
FOR OuterCounter IN 1 .. 100 LOOP --- table prefix in which it is to be inserted
FOR InnerCounter IN 1 .. 100 LOOP --- records to be inserted
sql_string := 'INSERT INTO emp_a' || Outercounter || ' (id, col_a, col_b, col_c, col_d, col_e, col_f, col_g, col_h, col_j)
VALUES ('
|| InnerCounter || ', to_char( ''col_a''' || innercounter || '),'
|| InnerCounter || ', to_char( ''col_d''' || innercounter || '),'
|| ', to_char( ''col_e''' || innercounter || '),'
|| ', to_char( ''col_f''' || innercounter || '),'
|| ', to_char( ''col_g''' || innercounter || '),'
|| ', to_char( ''col_h''' || innercounter || '),'
|| ', to_char( ''col_j''' || innercounter || '), SYSDATE)';
EXECUTE IMMEDIATE sql_string;
END LOOP;
END LOOP;
END;
DECLARE
ERROR at line 1:
ORA-00907: missing right parenthesis
ORA-06512: at line 17
please check the procedure and write the correct one...

Similar Messages

  • Help in inserting rows into a table

    I have a table called acct_fact,
    I need to insert rows in the table using a script but the problem is there's a column called seq_nbr which has random seq nbr of 14character length like 'ZWX98MGD9MVAD6J','ZWX98MG67RVAD6J' etc.,
    While inserting rows I need to generate such seq_nbr for those columns and insert rows into the table, can I use any such mechanism in my insert query to insert such random nbr's while inserting rows into a table.
    If so please suggest me

    Hi Peter,
    Thankyou for the quick reply:)
    can you suggest me how to implement it here in my script snippet:
    while read var_acct_nbr
    do
    echo "update acct_attr set acct_attr_exp_dt ='$ExpDate' where Acct_Attr_Value_Text='15' and acct_attr_exp_dt is null and person_id='LDCarrBillAgrm' and acct_nbr='$var_acct_nbr' ;" >> ./$DirectoryName/SQLQuery_$TimeStamp.sql
    echo "insert into acct_fact values ('$var_acct_nbr','$ExpDate','$ExpTime','*seq_nbr*','N','ProjTereza','Remoção de acordo d; data de expiração: $ExpDate',null,'1','LDE',null);" >> ./$DirectoryName/SQLQuery_$TimeStamp.sql
    done < ./$DirectoryName/ExpireAccts_$TimeStamp.LOG
    the script takes each acct_nbr nbr form a input file and fires an insert statement.
    The one in bold is the column where such sequence need to be inserted.can you help me in implementing the way you suggested in my script i.e., insert statement
    Thanks in Advance:)
    Edited by: rkrish on Jun 27, 2012 3:04 AM

  • Inserting rows into a table

    Hi,
    I want to insert values into a table 'Reasons'.
    The table 'Reason' has 5 columns
    out of 5 two columns has static data say
    column A value 'A'
    column E value sysdate
    But in the other three columns the vlues are repeating and as follows.
    Column B all rows of column x from table B
    Column C all rows of column y from table C
    Column D list of values as (ONE,TWO,THREE,FOUR)
    Please Help
    Thanks
    Rohit Taneja

    create table tableb(id number,x varchar2(20));
    insert into tableb values(1,'APPLE');
    insert into tableb values(2,'BANANA');
    insert into tableb values(3,'MANGO');
    create table tablec(id number,y varchar2(20));
    insert into tablec values(1,'ROHIT1');
    insert into tablec values(2,'ROHIT2');
    insert into tablec values(3,'ROHIT3');
    insert into tablec values(4,'ROHIT4');
    select 'A' AS COL_A, d.X AS COL_B,d.Y AS COL_C,
    to_char(to_date(ROW_NUMBER() OVER(PARTITION BY X,y ORDER BY X,Y),'YYYY'),'YYYYSP') AS COL_D,SYSDATE
    FROM ( select a.id , a.x X, b.y Y  from tableb a,tablec b , tablec e order by a.x) d
    ORDER BY d.X,d.Y
    C COL_B                COL_C                COL_D                                      SYSDATE
    A APPLE                ROHIT1               ONE                                        30-SEP-02
    A APPLE                ROHIT1               TWO                                        30-SEP-02
    A APPLE                ROHIT1               THREE                                      30-SEP-02
    A APPLE                ROHIT1               FOUR                                       30-SEP-02
    A APPLE                ROHIT2               ONE                                        30-SEP-02
    A APPLE                ROHIT2               TWO                                        30-SEP-02
    A APPLE                ROHIT2               THREE                                      30-SEP-02
    A APPLE                ROHIT2               FOUR                                       30-SEP-02
    A APPLE                ROHIT3               ONE                                        30-SEP-02
    A APPLE                ROHIT3               TWO                                        30-SEP-02
    A APPLE                ROHIT3               THREE                                      30-SEP-02
    A APPLE                ROHIT3               FOUR                                       30-SEP-02
    A APPLE                ROHIT4               ONE                                        30-SEP-02
    A APPLE                ROHIT4               TWO                                        30-SEP-02
    A APPLE                ROHIT4               THREE                                      30-SEP-02
    A APPLE                ROHIT4               FOUR                                       30-SEP-02
    A BANANA               ROHIT1               ONE                                        30-SEP-02
    A BANANA               ROHIT1               TWO                                        30-SEP-02
    A BANANA               ROHIT1               THREE                                      30-SEP-02
    A BANANA               ROHIT1               FOUR                                       30-SEP-02
    A BANANA               ROHIT2               ONE                                        30-SEP-02
    A BANANA               ROHIT2               TWO                                        30-SEP-02
    A BANANA               ROHIT2               THREE                                      30-SEP-02
    A BANANA               ROHIT2               FOUR                                       30-SEP-02
    A BANANA               ROHIT3               ONE                                        30-SEP-02
    A BANANA               ROHIT3               TWO                                        30-SEP-02
    A BANANA               ROHIT3               THREE                                      30-SEP-02
    A BANANA               ROHIT3               FOUR                                       30-SEP-02
    A BANANA               ROHIT4               ONE                                        30-SEP-02
    A BANANA               ROHIT4               TWO                                        30-SEP-02
    A BANANA               ROHIT4               THREE                                      30-SEP-02
    A BANANA               ROHIT4               FOUR                                       30-SEP-02
    A MANGO                ROHIT1               ONE                                        30-SEP-02
    A MANGO                ROHIT1               TWO                                        30-SEP-02
    A MANGO                ROHIT1               THREE                                      30-SEP-02
    A MANGO                ROHIT1               FOUR                                       30-SEP-02
    A MANGO                ROHIT2               ONE                                        30-SEP-02
    A MANGO                ROHIT2               TWO                                        30-SEP-02
    A MANGO                ROHIT2               THREE                                      30-SEP-02
    A MANGO                ROHIT2               FOUR                                       30-SEP-02
    A MANGO                ROHIT3               ONE                                        30-SEP-02
    A MANGO                ROHIT3               TWO                                        30-SEP-02
    A MANGO                ROHIT3               THREE                                      30-SEP-02
    A MANGO                ROHIT3               FOUR                                       30-SEP-02
    A MANGO                ROHIT4               ONE                                        30-SEP-02
    A MANGO                ROHIT4               TWO                                        30-SEP-02
    A MANGO                ROHIT4               THREE                                      30-SEP-02
    A MANGO                ROHIT4               FOUR                                       30-SEP-02
    48 rows selected.hope this is helpfull
    cheers
    prakash

  • Need to insert values into a table from a XML file

    Hi,
    I'm an Oracle 9i/10g DBA with quite a few years experience, but I'm new to XML and dealing with it in database terms. I've been given a project that entails pulling XML values out of a file (or 100's of them) and storing them in the database so that they are searchable by end-users. The project is classified as secret so I'm unable to upload the specific XML or any info relating to the structire of the XML or the table I will use to insert the values into - sorry!! So, I've created an XML file with a similar structure to help people understand my predicament.
    The end-users only need to search on a subset of the total amount of columns from the table I'll insert data into, although the XML file has a lot more, so I dont need to store the other values - but I will need to store the name of the XML file (or a pointer to it so I know what XML file a particular set of values belong to) in another column of the table along with its associated values.
    I've been using the XMLTABLE function with some degree of success, although I had better succes using the XMLSEQUENCE function. However, I found out this is deprecated in 10g and replaced with XMLTABLE, so I guess it's better if I use this in case we ever need to upgrade to 11g.
    The main problem I've been having is that some elements in the XML files have multiple values for the one record when all the other records are the same. In terms of storing this in the database, I guess it would mean inserting multiple rows in the table for each element where the value differs. Here is a dumbed down XML file similar to what I've got along with the other SQL I've used:
    +<?xml version="1.0" encoding="UTF-8"?>+
    +<House>+
    +<Warehouse>+
    +<WarehouseId>1</WarehouseId>+
    +<WarehouseName>+
    +<Town>Southlake</Town>+
    +<State>Texas</State>+
    +</WarehouseName>+
    +<Building>Owned</Building>+
    +<Area>25000</Area>+
    +<Docks>2</Docks>+
    +<DockType>Rear load</DockType>+
    +<WaterAccess>true</WaterAccess>+
    +<RailAccess>N</RailAccess>+
    +<Parking>Street</Parking>+
    +<VClearance>10</VClearance>+
    +</Warehouse>+
    +<Warehouse>+
    +<WarehouseId>2</WarehouseId>+
    +<WarehouseName>+
    +<Town>Poole</Town>+
    +<State>Dorset</State>+
    +</WarehouseName>+
    +<WarehouseName>+
    +<Town>Solihull</Town>+
    +<County>West Midlands</State>+
    +</WarehouseName>+
    +<Building>Owned</Building>+
    +<Area>40000</Area>+
    +<Docks>5</Docks>+
    +<DockType>Rear load</DockType>+
    +<WaterAccess>true</WaterAccess>+
    +<RailAccess>N</RailAccess>+
    +<Parking>Bay</Parking>+
    +<VClearance>10</VClearance>+
    +</Warehouse>+
    +<Warehouse>+
    +<WarehouseId>3</WarehouseId>+
    +<WarehouseName>+
    +<Town>Fleet</Town>+
    +<County>Hampshire</County>+
    +</WarehouseName>+
    +<Building>Owned</Building>+
    +<Area>10000</Area>+
    +<Docks>1</Docks>+
    +<DockType>Side load</DockType>+
    +<WaterAccess>false</WaterAccess>+
    +<RailAccess>N</RailAccess>+
    +<Parking>Bay</Parking>+
    +<VClearance>20</VClearance>+
    +</Warehouse>+
    +</House>+
    CREATE TABLE xmltest OF XMLTYPE;
    INSERT INTO xmltest
    VALUES(xmltype(bfilename('XML_DIR', 'test.xml'), nls_charset_id('AL32UTF8')));
    Consequently, I need to...
    1) Retrieve the results from the XML file for all 3 warehouses where multiple values for the same sub-element are shown as 2 rowsthe result set. (I am guessing there will be 4 rows returned as warehouse sub-2 has 2 different elements for <WarehouseName>.
    2) Build a case statement into the query so that regardless of the sub-element name (i.e State or County), it is returned into the 1 column, for instance County.
    So, if I run a query similar to the following...
    select y.WarehouseId, y.Town, y.County, y.Area
    from xmltest x, xmltable('/House/Warehouse' .......
    I would like to get results back like this...
    ID Town County Area
    1 Southlake Texas 25000
    2 Poole Dorset 40000
    2 Solihull West Midlands 40000
    3 Fleet hampshire 10000
    Sorry for the non-formatting but I hope this all makessense to someone out there with what I'm trying to do.
    I appreciate any help whatsoever because, as i said before, I'm totally new to XML and trying to read the vast amount of information there is out there on XML is all a bit daunting.
    Many thanks in advance,
    Shaun.

    Hi again,
    Thanks for keeping the post open for me. I've had a look at the post illustrating the XFileHandler package, and tried to alter it to make it fit with my XML files. To help explain things, my XML file looks like this:
    <?xml version="1.0"?>
    <!DOCTYPE  CMF_Doc SYSTEM "CMF_Doc.dtd">
    <House>
        <Warehouse>
        <WarehouseId>1</WarehouseId>
        <WarehouseName>
           <Town>Southlake</Town>
           <State>Texas</State>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>25000</Area>
        <Docks>2</Docks>
        <DockType>Rear load</DockType>
        <WaterAccess>true</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Street</Parking>
        <VClearance>10</VClearance>
      </Warehouse>
      <Warehouse>House
        <WarehouseId>2</WarehouseId>
        <WarehouseName>
           <Town>Poole</Town>
           <State>Dorset</State>
        </WarehouseName>
        <WarehouseName>
           <Town>Solihull</Town>
           <County>West Midlands</County>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>40000</Area>
        <Docks>5</Docks>
        <DockType>Rear load</DockType>
        <WaterAccess>true</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Bay</Parking>
        <VClearance>10</VClearance>
      </Warehouse>
      <Warehouse>
        <WarehouseId>3</WarehouseId>
        <WarehouseName>
           <Town>Fleet</Town>
           <County>Hampshire</County>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>10000</Area>
        <Docks>1</Docks>
        <DockType>Side load</DockType>
        <WaterAccess>false</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Bay</Parking>
        <VClearance>20</VClearance>
      </Warehouse>
    </House>
    <?xml version="1.0" encoding="UTF-8"?>
    <House>
        <Warehouse>
        <WarehouseId>4</WarehouseId>
        <WarehouseName>
           <Town>Dallas</Town>
           <State>Texas</State>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>25000</Area>
        <Docks>2</Docks>
        <DockType>Rear load</DockType>
        <WaterAccess>true</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Street</Parking>
        <VClearance>10</VClearance>
      </Warehouse>
      <Warehouse>
        <WarehouseId>5</WarehouseId>
        <WarehouseName>
           <Town>Dorchester</Town>
           <State>Dorset</State>
        </WarehouseName>
        <WarehouseName>
           <Town>Solihull</Town>
           <County>West Midlands</County>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>40000</Area>
        <Docks>5</Docks>
        <DockType>Rear load</DockType>
        <WaterAccess>true</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Bay</Parking>
        <VClearance>10</VClearance>
      </Warehouse>
      <Warehouse>
        <WarehouseId>6</WarehouseId>
        <WarehouseName>
           <Town>Farnborough</Town>
           <County>Hampshire</County>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>10000</Area>
        <Docks>1</Docks>
        <DockType>Side load</DockType>
        <WaterAccess>false</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Bay</Parking>
        <VClearance>20</VClearance>
      </Warehouse>
    </House>
    <?xml version="1.0" encoding="UTF-8"?>
    <House>
        <Warehouse>
        <WarehouseId>7</WarehouseId>
        <WarehouseName>
           <Town>Southlake</Town>
           <State>Texas</State>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>25000</Area>
        <Docks>2</Docks>
        <DockType>Rear load</DockType>
        <WaterAccess>true</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Street</Parking>
        <VClearance>10</VClearance>
      </Warehouse>
      <Warehouse>
        <WarehouseId>8</WarehouseId>
        <WarehouseName>
           <Town>Bournemouth</Town>
           <State>Dorset</State>
        </WarehouseName>
        <WarehouseName>
           <Town>Shirley</Town>
           <County>West Midlands</County>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>30000</Area>
        <Docks>5</Docks>
        <DockType>Rear load</DockType>
        <WaterAccess>true</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Bay</Parking>
        <VClearance>10</VClearance>
      </Warehouse>
      <Warehouse>
        <WarehouseId>9</WarehouseId>
        <WarehouseName>
           <Town>Clapham</Town>
           <County>London</County>
        </WarehouseName>
        <Building>Owned</Building>
        <Area>10000</Area>
        <Docks>1</Docks>
        <DockType>Side load</DockType>
        <WaterAccess>false</WaterAccess>
        <RailAccess>N</RailAccess>
        <Parking>Bay</Parking>
        <VClearance>20</VClearance>
      </Warehouse>
    </House>And the XFilehandler package looks like this (I'm just trying to do a simple select only on WarehouseId & WaterAccess for the time being to keep things simple):
    create or replace package XFileHandler as
      TYPE TRECORD IS RECORD (
        WID     NUMBER(2)
      , WACCESS VARCHAR2(5)
      type TRecordTable is table of TRecord;
      function getRows (p_directory in varchar2, p_filename in varchar2) return TRecordTable pipelined;
    end;
    create or replace package body XFileHandler is
      function getRows (p_directory in varchar2, p_filename in varchar2)
       return TRecordTable pipelined
      is
        nb_rec          number := 1;
        tmp_xml        clob;
        tmp_file         clob;
        rec               TRecord;
      begin
        DBMS_LOB.CREATETEMPORARY(TMP_FILE, TRUE);
        tmp_file := dbms_xslprocessor.read2clob(p_directory, p_filename);
        LOOP
          tmp_xml := regexp_substr(tmp_file, '<\?xml[^?]+\?>\s*<([^>]+)>.*?</\1>', 1, nb_rec, 'n');
          exit when length(tmp_xml) = 0;
          --dbms_output.put_line(tmp_rec);
          nb_rec := nb_rec + 1;
        select y.WID, y.WACCESS
        into rec.WID, rec.WACCESS
        from xmltable('/House' passing xmltype(tmp_xml)
                      columns WID NUMBER(2) PATH 'Warehouse/WarehouseId',
                                  WACCESS VARCHAR2(5) PATH 'WaterAccess') y;
          pipe row ( rec );
        end loop;
        dbms_lob.freetemporary(tmp_file);
        return;
      end;
    end;Now, when I run the query:
    select * from table(XFileHandler.getRows('XML_DIR', 'XFileHandler_test.xml'));I get the error: ORA-00600: internal error code, arguments: [17285], [0x5CFE8DC8], [4], [0x45ABE1C8], [], [], [], []
    I had a look in the dump file for anything obvious, but nothing really stands out. Is there anything obvious in my code that I'm missing or something else which you may think could be causing this error, e.g in the regular expression regexp_substr?
    Many thanks,
    Shaun.

  • Insert row into database table via dynamic form -

    I have developed a portlet via Portal. I used a dynamic page. I replaced the default "<ORACLE>select * from scott.emp</ORACLE>" text to call a package procedure that uses HTP.P to render the web page. My goal is to show all rows in a table and allow edits to any row, and also add a checkbox on each row to allow the user to mark for delete. I am successfully using a FOR loop and showing all of the data in a grid. My problem - How do I update and delete the data? I have a submit button with nothing behind it currently. I would ideally like to use pl/sql code to do the updates and/or deletes as marked on the page by the user, but I'm not sure how to hook the submit button to calling a procedure to execute the updates/deletes.
    Any help would be appreciated -
    Thanks -
    Kent

    Hi Patrick - Thanks for your response! I have browsed your page quickly - very informative and I will look in more detail. My form design looks as below (using a simple example with emp id and emp name columns) - perhaps this will have to change, but I wanted the user to be able to insert using html fields id_add and name_add, then update (or mark for deletion) any of the existing rows (they are rendered with for loop in pl/sql - eg, id_1/name_1, id_2/name_2, etc for each row in the table). I was hoping the submit action would call a pl/sql that would look at all rows, and then act if an update or delete were required. This makes it difficult to use parms, I believe - I may be able to change the design to show an "update row" below the current "insert row" so that, as in your example, when the user highlights a row, it populates in the update area where changes can be made, and an update button used to effect the changes to a single row at a time.
    Thanks again, I appreciate your input!
    Kent
    ______________ _________________ <insert_button>
    Emp Id (textbox) Emp Name (textbox) Del_Checkbox
    ______________ _________________ ___ <SUBMIT_BUTTON>
    ------------------------- ----------------------------- ------

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

  • Unable to insert rows into the table

    My insert statement below is not correct, when i try run, its encoutering error "table or view does not exist".
    Basically what i am doing here is collecting the table name in FOR variable which stores the table name in this variable. This variable, i am using as table. I know this is not the proper way, please let me how can insert the complete table rows with the following code.
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM Comp WHERE 1=2;
    DECLARE
         I INTEGER DEFAULT 1;
    S VARCHAR2(50);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CABLE%' and TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    INSERT INTO TEMP SELECT * FROM c.TABLE_NAME;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    The above insert statement is not correct. How can i write proper way.
    Thanks.
    Best Regards
    Arshad

    user13360241 wrote:
    My insert statement below is not correct, when i try run, its encoutering error "table or view does not exist".
    Basically what i am doing here is collecting the table name in FOR variable which stores the table name in this variable. This variable, i am using as table. I know this is not the proper way, please let me how can insert the complete table rows with the following code.
    DROP TABLE TEMP;
    CREATE TABLE TEMP AS SELECT * FROM Comp WHERE 1=2;
    DECLARE
         I INTEGER DEFAULT 1;
    S VARCHAR2(50);
    begin
    for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CABLE%' and TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
    INSERT INTO TEMP SELECT * FROM c.TABLE_NAME;
    dbms_output.put_line(c.table_name);
    end loop;
    end;
    The above insert statement is not correct. How can i write proper way.
    Thanks.
    Best Regards
    ArshadSTMT := 'INSERT INTO TEMP SELECT * FROM ';
    STMT := STMT || S;
    EXECUTE IMMEDIATE STMT;

  • Insert rows into a table in particular order

    When i fired a query as
    insert into table1 select * from table2 order by req_id .
    It is not inserting into table1 as ordered by req_id.Please suggest

    ORDER is irrelevant when it comes to storage of data unless its Index organized table. In a Heap Organized table the order in which data is stored is irrelevant.
    Here is a small example to show the difference between IOT and HOT.
    SQL> create table hot (no integer)
      2  /
    Table created.
    SQL> create table iot (no integer primary key) organization index
      2  /
    Table created.
    SQL> insert into hot select level from dual connect by level <= 10 order by dbms_random.value
      2  /
    10 rows created.
    SQL> select * from hot
      2  /
            NO
             7
             6
             4
             5
            10
             3
             1
             9
             8
             2
    10 rows selected.
    SQL> insert into iot select level from dual connect by level <= 10 order by dbms_random.value
      2  /
    10 rows created.
    SQL> select * from iot
      2  /
            NO
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.Thanks,
    Karthick.
    Edited by: Karthick_Arp on Feb 5, 2009 3:45 AM

  • Inserting rows into table Based on Column Values.

    Hi,
    I am trying to inserting rows into a table based on Column.
    Id      Name        
    Data
    N 105.1.1
    http://www.example.com/New/105.1.1
    U 105.1.2               http://www.example.com/Used/105.1.2
    S 105.1.3               http://www.example.com/Sold/105.1.3
    I want a table like this. 
    I want to insert Data column value based on Id and Name Columns
    If Id = N and Name = 105.1.1 then Data value should be insert as   http://www.example.com/New/105.1.1
    If Id = U and Name = 105.1.2 then Data value should be  insert as  http://www.example.com/Used/105.1.2
    If Id = S and Name = 105.1.3 then Data value should be insert as   http://www.example.com/Sold/105.1.3
    Can you please help us to write query to insert above Data Column values based on Id and Name Columns.

    INSERT INTO tbl (col) SELECT
    CASE WHEN id='N' and Name='105.1.1 ' THEN 'http://www.example.com/New/105.1.1'
              WHEN id='U' and Name='105.1.2 ' THEN 'http://www.example.com/New/105.1.2'
    END col
    FROM anothertbl
    Sorry , cannot test it right now.
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Adding 2 more rows to a select without inserting rows to base table

    hello all,
    i have a below simple select statement which is querying a table.
    select * from STUDY_SCHED_INTERVAL_TEMP
    where STUDY_KEY = 1063;
    but here is the situations. As you can see its returning 7 rows. But i need to add
    2 more rows..with everything else default value or what exist... except adding 2 more rows.
    i cannot insert into base table. I want my end results to increment by 2 days in
    measurement_date_Taken to 01-apr-09....so basically measurement_date_taken should
    end at study_end_Date...
    IS THAT EVEN POSSIBLE WITHOUT INSERTING ROWS INTO THE TABLE AND JUST PLAYIHY AROUND WITH
    THE SELECT STATEMENT??
    sorry if this is confusing...i am on 10.2.0.3
    Edited by: S2K on Aug 13, 2009 2:19 PM

    Well, I'm not sure if this query looks as good as my lawn, but seems to work anyway ;)
    I've used the 'simplified version', but the principle should work for your table to, S2K.
    As Frank already pointed out (and I stumbled upon it while clunging): you just select your already existing rows and union them with the 'missing records', you calculate the number of days you're 'missing' based on the study_end_date:
    MHO%xe> alter session set nls_date_language='AMERICAN';
    Sessie is gewijzigd.
    Verstreken: 00:00:00.01
    MHO%xe> with t as ( -- generating your data here, simplified by me due to cat and lawn
      2  select 1063 study_key
      3  ,      to_date('01-MAR-09', 'dd-mon-rr') phase_start_date
      4  ,      to_date('02-MAR-09', 'dd-mon-rr') measurement_date_taken
      5  ,      to_date('01-APR-09', 'dd-mon-rr') study_end_date
      6  from dual union all
      7  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('04-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
      8  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('09-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
      9  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('14-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
    10  select 1063, to_date('03-MAR-09', 'dd-mon-rr') , to_date('19-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
    11  select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('23-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual union all
    12  select 1063, to_date('22-MAR-09', 'dd-mon-rr') , to_date('30-MAR-09', 'dd-mon-rr') , to_date('01-APR-09', 'dd-mon-rr') from dual
    13  ) -- actual query:
    14  select study_key
    15  ,      phase_start_date
    16  ,      measurement_date_taken
    17  ,      study_end_date
    18  from   t
    19  union all
    20  select study_key
    21  ,      phase_start_date
    22  ,      measurement_date_taken + level -- or rownum
    23  ,      study_end_date
    24  from ( select study_key
    25         ,      phase_start_date
    26         ,      measurement_date_taken
    27         ,      study_end_date
    28         ,      add_up
    29         from (
    30                select study_key
    31                ,      phase_start_date
    32                ,      measurement_date_taken
    33                ,      study_end_date
    34                ,      study_end_date - max(measurement_date_taken) over (partition by study_key
    35                                                                          order by measurement_date_taken ) add_up
    36                ,      lead(measurement_date_taken) over (partition by study_key
    37                                                          order by measurement_date_taken ) last_rec
    38                from   t
    39              )
    40         where last_rec is null
    41       )
    42  where rownum <= add_up
    43  connect by level <= add_up;
    STUDY_KEY PHASE_START_DATE    MEASUREMENT_DATE_TA STUDY_END_DATE
          1063 01-03-2009 00:00:00 02-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 04-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 09-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 14-03-2009 00:00:00 01-04-2009 00:00:00
          1063 03-03-2009 00:00:00 19-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 23-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 30-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 31-03-2009 00:00:00 01-04-2009 00:00:00
          1063 22-03-2009 00:00:00 01-04-2009 00:00:00 01-04-2009 00:00:00
    9 rijen zijn geselecteerd.If there's a simpler way (in SQL), I hope others will join and share their example/ideas/thoughts.
    I have a feeling that this is using more resources than needed.
    But I've got to cut the daisies first now, they interfere my 'lawn-green-ess' ;)

  • Error while inserting rows in a table

    Hi,
    We have recently migrated from 9i to 10g. We have a scheduled job out our DB which first deletes all the rows from a table and then inserts them back by selecting rows from 5 tables. This table has a composite primary key based on 6 columns in it. In 9i, when i try to insert rows into the table after deleting all the rows from it, I am able to insert the data successfully . However, in 10g, when i try doing the same operation, it fails with the ORA error:
    ORA-00001: unique constraint violated
    The same query which works perfectly in 9i fails in 10g
    If anybody has some ideas on how to resolve the same, kindly let me know.
    Thanks in advance.

    Hi,
    I was finally able to resolve the reason behind that error message and found it even more weird. The error was because I was using the substr function for extracting the characters 1-4 from a column which is 5 characters long. When i specify the query as:
    select substr(column1, 1, 4)) from table1;
    only the characters 1-3 are retrieved. Now if i change the query to select substr(column1, 1, 5)) from table1, in that case also only 3 characters are retrieved although i have specified the substr to start from 1 and read till 5 characters. Also, when i run the query:
    select length(substr(column1, 1, 4)) from table1 or select length(substr(column1, 1, 5)) from table1
    I get the answer as 3.
    However, the most amazing part is that the query is working perfectly in 9i and is retrieving the data correctly i.e. from substr 1-4.
    Can anyone suggest what the problem could be?
    Thanks
    Edited by: CrazyAnie on May 13, 2009 1:34 AM

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

  • Insert data into oracle table from XML file

    I need to insert data into oracle table from XML file
    If anybody handled this type of scenario, Please let me know how to insert data into oracle table from XML file
    Thanks in advance

    The XML DB forum provides the best support for XML topics related to Oracle.
    Here's the FAQ on that forum:
    XML DB FAQ
    where there are plenty of examples of shredding XML into Oracle tables and such like. ;)

  • Insert data into a table without identity column

    Hi,
    I need to insert data into a table using data flow task. Unfortunately this table's priamry key column (integer column) is not identity column.  I am looking a way to get the primary key value for the new records. Please advice. Thanks

    Phil has a great post on generating surrogate keys in SSIS: http://www.ssistalk.com/2007/02/20/generating-surrogate-keys/

  • Error inserting a row into a table with identity column using cfgrid on change

    I got an error on trying to insert a row into a table with identity column using cfgrid on change see below
    also i would like to use cfstoreproc instead of cfquery but which argument i need to pass and how to use it usually i use stored procedure
    update table (xxx,xxx,xxx)
    values (uu,uuu,uu)
         My component
    <!--- Edit a Media Type  --->
        <cffunction name="cfn_MediaType_Update" access="remote">
            <cfargument name="gridaction" type="string" required="yes">
            <cfargument name="gridrow" type="struct" required="yes">
            <cfargument name="gridchanged" type="struct" required="yes">
            <!--- Local variables --->
            <cfset var colname="">
            <cfset var value="">
            <!--- Process gridaction --->
            <cfswitch expression="#ARGUMENTS.gridaction#">
                <!--- Process updates --->
                <cfcase value="U">
                    <!--- Get column name and value --->
                    <cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
                    <cfset value=ARGUMENTS.gridchanged[colname]>
                    <!--- Perform actual update --->
                    <cfquery datasource="#application.dsn#">
                    UPDATE SP.MediaType
                    SET #colname# = '#value#'
                    WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
                    </cfquery>
                </cfcase>
                <!--- Process deletes --->
                <cfcase value="D">
                    <!--- Perform actual delete --->
                    <cfquery datasource="#application.dsn#">
                    update SP.MediaType
                    set Deleted=1
                    WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
                    </cfquery>
                </cfcase>
                <cfcase value="I">
                    <!--- Get column name and value --->
                    <cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
                    <cfset value=ARGUMENTS.gridchanged[colname]>
                    <!--- Perform actual update --->
                   <cfquery datasource="#application.dsn#">
                    insert into  SP.MediaType (#colname#)
                    Values ('#value#')              
                    </cfquery>
                </cfcase>
            </cfswitch>
        </cffunction>
    my table
    mediatype:
    mediatypeid primary key,identity
    mediatypename
    my code is
    <cfform method="post" name="GridExampleForm">
            <cfgrid format="html" name="grid_Tables2" pagesize="3"  selectmode="edit" width="800px" 
            delete="yes"
            insert="yes"
                  bind="cfc:sp3.testing.MediaType.cfn_MediaType_All
                                                                ({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})"
                  onchange="cfc:sp3.testing.MediaType.cfn_MediaType_Update({cfgridaction},
                                                {cfgridrow},
                                                {cfgridchanged})">
                <cfgridcolumn name="MediaTypeID" header="ID"  display="no"/>
                <cfgridcolumn name="MediaTypeName" header="Media Type" />
            </cfgrid>
    </cfform>
    on insert I get the following error message ajax logging error message
    http: Error invoking xxxxxxx/MediaType.cfc : Element '' is undefined in a CFML structure referenced as part of an expression.
    {"gridaction":"I","gridrow":{"MEDIATYPEID":"","MEDIATYPENAME":"uuuuuu","CFGRIDROWINDEX":4} ,"gridchanged":{}}
    Thanks

    Is this with the Travel database or another database?
    If it's another database then make sure your columns
    allow nulls. To check this in the Server Navigator, expand
    your DataSource down to the column.
    Select the column and view the Is Nullable property
    in the Property Sheet
    If still no luck, check out a tutorial, like Performing Inserts, ...
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/index.jsp
    John

Maybe you are looking for

  • GRC Inbound - setar step POASSIGN manualmente

    Bom dia Pessoal, Preciso de uma ajuda, alguém sabe se é possível setar o step POASSIGN do GRC Inbound para Definido como OK manualmente? Pergunto isso porque a solução aqui do projeto é que alguns passos do processo que o GRC faz sejam feitos por um

  • Import preferences and question about import

    Under Preferences/Advanced is the selection: "Copy files to iPhoto Library folder when adding to library." Should this option be selected? What does it do? When I import, neither roll nor photo name appear in the left menu window of iPhoto. Other rol

  • Iphoto can't import .CR2 shot with manual lenses on intel imac

    I'm shooting with a Peleng 8mm on my Canon REBEL Xt, it is a manual lens and my problem is that all the pictures shot with regular EF lenses can be imported in iPhoto, but the ones shot with the Peleng freeze the import process. I got this problem on

  • Backup itouch on another mac and not lose whats on itouch when sync

    backup itouch on another mac and not lose whats on itouch when sync

  • Portal Test Connection Failed for JDBC Connector

    Hi, We are trying to create a JDBC system in EP to connect SQL Server 2005 database. Our aim is to build a model in VC using data services from SQL Server 2005. We deployed the Driver file sqljdbc.jar  and connection was successful when tested by cre