Cfloop + Multiple DB Inserts

Hello everyone. I have a form with a dynamically generated
number of fields. Each Client has a variable number of
"ItemDetails" assigned to them based upon which Item that
individual is registered for.
For example: Customer A is registered for a HRID (Item). This
Item in turn has several item details (manager id, LikeUserID,
Role, Organization, etc etc..) Bear in mind that someone
registered for a different item (ERPID2) may be assigned a
different
number of item details. That's the basic explanation of the
form. This is a "Change" Form that I am working on. The way the
page is setup, a textbox for each itemdetail (along with the
Item Details Name) will display on the page. Note, only one Item
will display per page. There is one buttton ("Change"). When
this button is impressed I want these values the User has
input to be inserted into a new table I have created. I do
not want these values to overwrite the original ones as they must
be
approved by a manager first. Basically I need a dynamic
insert query that will perform an insert for each item detail. I've
looked on the web and a lot of people use a <cfloop index
= "list element"> but since I'm not using a list (for now) it
doesn't
really apply to me. I guess I'm just looking for some ideas
on how to do this. Any help would be great. If you know any
examples on the web, please send me the links.
Thanks Again!

Sorry about that I forgot to mention one other detail. On the
topic of "list" what I meant was is that
there are no Itemdetails that have "selectable values" (ie
can't have more than one value per
itemdetail) in a multiselect box. The sql pulls up all the
itemdetails assigned to that person (for that
item) and all the values for those item details (one value
per itemdetail).
What I need is an insert statement that will perform multiple
inserts using information retrieved from
other queries. The information input into the textboxs by
users will also be used to fill in one of the
fields (NewItemValue) while the 3 remaining fields (ItemID,
ItemDetailID, ActionItemID) will be filled in
from data from other queries. Here's an example query I'm
working with.
<cfif isdefined "Submit>
<cfquery name ="ItemDetailInsert>
Insert Into ItemDetailUpdates (ItemID, ItemDetailID,
NewItemValue, ActionItemID)
Values (#queryA.ItemID#, #queryA.ItemDetailID#,
#form.NewItemValue#ID##,
#queryB.ActionItemID#)
</cfquery>
My question here is: Will this query work as it is now? I
want this query to do multiple inserts so should I put this query
in a cfloop? or will the query automatically know to keep inserting
data until their is no data left to insert?Any help would be
appreciated.
Thanks again for all your help.

Similar Messages

  • Multiple row insert not working as before after applying hotfix apsb13-13

    Coldfusion 9.01
    Windows Server 2003
    Microsoft Access database (yeah, we know)
    Before the hotfix was applied, we could add multiple rows (anywhere from 1-100 or more) and now we're limited to 15 rows at a time after applying the hotfix. We've narrowed it down to the hotfix being the culprit as we had to rebuild the server not to long after this hotfix was applied (~ 1 month) and the multiple row inserts were once again working fine until we got to the point of applying this hot fix again.
    Anyone heard of this happening? Any ideas how to correct?
    Thanks in advance,
    fmHelp
    Below is code  of how we're doing the multiple row insert (it's performed over 3 pages):
    Page 1
    <cfform name="form1" method="post" action="handler.cfm?page=update_2">
    <input type="hidden" name="sProductID" value="<cfoutput>#qProducts.sProductID#</cfoutput>">
    <table width="100%" border="0" cellspacing="3" cellpadding="3">
      <tr>
        <th scope="row" colspan="2" align="center">Update an Inventory Product</th>
      </tr>
      <tr>
        <th width="42%" scope="row">Product ID</th>
        <td width="58%"><cfoutput>#qProducts.sProductID#</cfoutput></td>
      </tr>
      <tr>
        <th width="42%" scope="row">Friendly Name</th>
        <td width="58%"><cfoutput>#qProducts.sFriendly_Name#</cfoutput></td>
      </tr>
      <tr>
        <th width="42%" scope="row">Description</th>
        <td width="58%"><cfoutput>#qProducts.sDescription#</cfoutput></td>
      </tr>
      <tr>
        <th width="42%" scope="row">Vendor</th>
        <td><select name="sVendor">
          <cfoutput><option value="#qProducts.sVendor#">#qProducts.sVendor#</option></cfoutput>
          <option value=""></option>
          <cfoutput query="qVendor">
            <option value="#sVendor#">#sVendor#</option>
          </cfoutput>
        </select></td>
      </tr>
      <tr>
        <th scope="row">Order No.</th>
        <td><cfinput name="sOrder_No" type="text" value="" required="yes" message="Order number is a required field."></td>
      </tr>
      <tr>
        <th scope="row">Lot No.</th>
        <td><input name="sLot" type="text" value=""/></td>
      </tr>
      <tr>
        <th scope="row">Date Expires</th>
        <td><input name="dtExpire" type="text" value=""/></td>
      </tr>
      <tr>
        <th scope="row">Boxes received</th>
        <td><input name="iBoxes" type="text" value="" /></td>
      </tr>
      <tr>
        <th scope="row">Doses/Units</th>
        <td><input name="pcount" type="text" value="" /></td>
      </tr>
      <tr>
        <th scope="row">Note</th>
        <td><cfoutput>#qProducts.sNote#</cfoutput></td>
      </tr>
      <tr>
        <th scope="row"> </th>
        <td> </td>
      </tr>
      <tr>
        <th scope="row" colspan="2" align="center"><input type="submit" value="Submit" /></th>
      </tr>
    </table>
    </cfform>
    </table>
    Page 2
    <form name="form1" method="post" action="handler.cfm?page=update_3">
    <cfoutput><input type="hidden" name="pcount" value="#FORM.pcount#"></cfoutput>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
              <td colspan="6" align="left">Record count (Doses/Units)= <cfoutput>#FORM.pcount#</cfoutput></td>
        </tr>
        <tr>
            <td>Product ID</td>
            <td>Vendor</td>
            <td>Order No.</td>
            <td>Lot No.</td>
            <td>Expiration Date</td>
            <td>Num. of Boxes</td>
        </tr>
        <cfset Peoplecount = 0>
        <cfloop index="Add" from="1" to="#form.pcount#" step="1">
            <tr>
                <cfset Peoplecount = PeopleCount + 1>
                <td><input  <cfoutput> value="#FORM.sProductID#" </cfoutput> name="sProductID_<cfoutput>#Peoplecount#</cfoutput>" type="text" id="sProductID_"></td>
                <td><input <cfoutput>value="#FORM.sVendor#"</cfoutput> name="sVendor_<cfoutput>#Peoplecount#</cfoutput>" type="text" id="sVendor_"></td>
                <td><input  <cfoutput> value="#FORM.sOrder_No#" </cfoutput> name="sOrder_No_<cfoutput>#Peoplecount#</cfoutput>" type="text" id="sOrder_No_"></td>
                <td><input <cfoutput>value="#FORM.sLot#"</cfoutput> name="sLot_<cfoutput>#Peoplecount#</cfoutput>" type="text" id="sLot_"></td>
                <td><input  <cfoutput> value="#DateFormat(FORM.dtExpire, 'MM/DD/YY')#" </cfoutput> name="dtExpire_<cfoutput>#Peoplecount#</cfoutput>" type="text" id="dtExpire_"></td>
                <td><input <cfoutput>value="#FORM.iBoxes#"</cfoutput> name="iBoxes_<cfoutput>#Peoplecount#</cfoutput>" type="text" id="iBoxes_"></td>
            </tr>
        </cfloop>
        <tr>
            <td> </td>
            <td>
                <input type="submit" name="Submit" value="Submit">
                <input name="HowMany" type="hidden" id="HowMany" value="<cfoutput>#Form.pcount#</cfoutput>">
            </td>
        </tr>
    </table>
    </form>
    </table>
    Page 3
    <cfquery name="qGetOnHand" datasource="#variables.DSNCI#">
    SELECT        *
    FROM        Products
    WHERE        sProductID = '#session.sProductID#'
    </cfquery>
    <cfquery datasource="#variables.DSNCI#">
    UPDATE        Products
    SET            iOnHandQty = (#FORM.pcount# + #qGetOnHand.iOnHandQty#)
    WHERE        sProductID = '#session.sProductID#'
    </cfquery>           
    <cfset quantity = #FORM.pcount#>
    <cfset Pcount = 0>
    <!-- Start Loop -->
    <cfloop index="Add" from="1" to="#form.howmany#" step="1">
        <cfset Pcount = Pcount + 1>
        <cfset Product = "Form.sProductID_#Pcount#">
        <cfset Product = Evaluate(Product)>
        <cfset Vendor = "Form.sVendor_#Pcount#">
        <cfset Vendor = Evaluate(Vendor)>
        <cfset Order  = "Form.sOrder_No_#Pcount#">
        <cfset Order = Evaluate(Order)>
        <cfset Lot = "Form.sLot_#Pcount#">
        <cfset Lot = Evaluate(Lot)>
        <cfset Expires = "Form.dtExpire_#Pcount#">
        <cfset Expires = Evaluate(Expires)>
        <cfset Boxes = "Form.iBoxes_#Pcount#">
        <cfset Boxes = Evaluate(Boxes)>
        <cfquery datasource="#variables.DSNCI#" name="InsertData">
            Insert into Received_History (sProductID, sVendor, sOrder_No, sLot, dtExpire, iBoxes, dtReceived)
            values ('#Product#', '#Vendor#', '#Order#', '#Lot#', <cfif Expires IS "">NULL<cfelse>#CreateOdbcDate(Expires)#</cfif>, #Boxes#, #CreateOdbcDate(Now())#)
        </cfquery>
    </cfloop>

    Rasi wrote:show your complete default.pa (also make sure that you dont override pulse settings in ~/.config/pulse) this setting should allow sound for ANY user - i just tried it and it works
    also: of course you restarted pulseaudio?
    I restarted pulseaudio and my computer.
    My default.pa is displayed in the first post.
    My files in /etc/pulse:
    > ls -la /etc/pulse
    total 28
    drwxr-xr-x 1 root root 116 May 16 10:22 .
    drwxr-xr-x 1 root root 3740 May 16 10:47 ..
    -rw-r--r-- 1 root root 1269 Mar 3 21:31 client.conf
    -rw-r--r-- 1 root root 2348 Oct 8 2013 daemon.conf
    -rw-r--r-- 1 root root 5756 May 16 10:24 default.pa
    -rw-r--r-- 1 root root 5718 Oct 8 2013 default.pa.pacnew
    -rw-r--r-- 1 root root 2112 Oct 8 2013 system.pa
    -la
    My files in ~/.config/pulse:
    > ls -la ~/.config/pulse
    total 1048
    drwx------ 1 homeuser homeuser 660 Sep 12 2013 .
    drwx------ 1 homeuser homeuser 1054 Apr 24 14:06 ..
    -rw-r--r-- 1 homeuser homeuser 40960 Oct 17 2013 1a8726d55f9140ae9d95dc512eacea67-card-database.tdb
    -rw-r--r-- 1 homeuser homeuser 43 May 16 10:37 1a8726d55f9140ae9d95dc512eacea67-default-sink
    -rw-r--r-- 1 homeuser homeuser 42 May 16 10:37 1a8726d55f9140ae9d95dc512eacea67-default-source
    -rw-r--r-- 1 homeuser homeuser 12288 May 16 10:49 1a8726d55f9140ae9d95dc512eacea67-device-volumes.tdb
    lrwxrwxrwx 1 homeuser homeuser 23 Sep 12 2013 1a8726d55f9140ae9d95dc512eacea67-runtime -> /tmp/pulse-cDmMRoO9oFBz
    -rw-r--r-- 1 homeuser homeuser 12288 May 15 22:43 1a8726d55f9140ae9d95dc512eacea67-stream-volumes.tdb
    -rw------- 1 homeuser homeuser 256 Jun 15 2013 cookie
    -rw-r--r-- 1 homeuser homeuser 331776 Jun 21 2013 equalizer-presets.tdb
    -rw-r--r-- 1 homeuser homeuser 659456 Sep 20 2013 equalizer-state.tdb
    Thanks for your efforts.

  • How can I use multiple row insert or update into DB in JSP?

    Hi all,
    pls help for my question.
    "How can I use multiple rows insert or update into DB in JSP?"
    I mean I will insert or update the multiple records like grid component. All the data I enter will go into the DB.
    With thanks,

    That isn't true. Different SQL databases have
    different capabilities and use different syntax, That's true - every database has its own quirks and extensions. No disagreement there. But they all follow ANSI SQL for CRUD operations. Since the OP said they wanted to do INSERTs and UPDATEs in batches, I assumed that ANSI SQL was sufficient.
    I'd argue that it's best to use ANSI SQL as much as possible, especially if you want your JDBC code to be portable between databases.
    and there are also a lot of different ways of talking to
    SQL databases that are possible in JSP, from using
    plain old java.sql.* in scriptlets to using the
    jstlsql taglib. I've done maintenance on both, and
    they are as different as night and day.Right, because you don't maintain JSP and Java classes the same way. No news there. Both java.sql and JSTL sql taglib are both based on SQL and JDBC. Same difference, except that one uses tags and the other doesn't. Both are Java JDBC code in the end.
    Well, sure. As long as you only want to update rows
    with the same value in column 2. I had the impression
    he wanted to update a whole table. If he only meant
    update all rows with the same value in a given column
    with the same value, that's trivial. All updates do
    that. But as far as I know there's know way to update
    more than one row where the values are different.I used this as an example to demonstrate that it's possible to UPDATE more than one row at a time. If I have 1,000 rows, and each one is a separate UPDATE statement that's unique from all the others, I guess I'd have to write 1,000 UPDATE statements. It's possible to have them all either succeed or fail as a single unit of work. I'm pointing out transaction, because they weren't coming up in the discussion.
    Unless you're using MySQL, for instance. I only have
    experience with MySQL and M$ SQL Server, so I don't
    know what PostgreSQL, Oracle, Sybase, DB2 and all the
    rest are capable of, but I know for sure that MySQL
    can insert multiple rows while SQL Server can't (or at
    least I've never seen the syntax for doing it if it
    does).Right, but this syntax seems to be specific to MySQL The moment you use it, you're locked into MySQL. There are other ways to accomplish the same thing with ANSI SQL.
    Don't assume that all SQL databases are the same.
    They're not, and it can really screw you up badly if
    you assume you can deploy a project you've developed
    with one database in an environment where you have to
    use a different one. Even different versions of the
    same database can have huge differences. I recommend
    you get a copy of the O'Reilly book, SQL in a
    Nutshell. It covers the most common DBMSes and does a
    good job of pointing out the differences.Yes, I understand that.
    It's funny that you're telling me not to assume that all SQL databases are the same. You're the one who's proposing that the OP use a MySQL-specific extension.
    I haven't looked at the MySQL docs to find out how the syntax you're suggesting works. What if one value set INSERT succeeds and the next one fails? Does MySQL roll back the successful INSERT? Is the unit of work under the JDBC driver's control with autoCommit?
    The OP is free to follow your suggestion. I'm pointing out that there are transactions for units of work and ANSI SQL ways to accomplish the same thing.

  • SQLite Multiple rows insert

    Hi,
    I know this question has been asked and there was an answer:
    http://stackoverflow.com/questions/1609637/is-it-possible-to-insert-multiple-rows-at-a-tim e-in-an-sqlite-database
    But now things has changed, from version 3.7.11 SQLite does work normally with multiple insert:
    http://stackoverflow.com/questions/1609637/is-it-possible-to-insert-multiple-rows-at-a-tim e-in-an-sqlite-database
    http://www.sqlite.org/lang_insert.html
    Now the problem is that I use SQLite Expert to perform a multiple row insert with normal sql method:
    INSERT INTO table (col1, col2) VALUES
          ('row1col1', 'row1col2'), ('row2col1', 'row2col2'), ...
    And this works. However when I try to use this insert within Flash Builder it gives me an error - syntax error near ",".
    Is there a way I can check or update SQLite within Flex so I could use multiple row insert?
    Thanks in advance for answers:)

    Unlike in php (values(product1),(product2),(product3))
    you cannot insert records like that in a sqlite db.
    What i did is the following
    public function insertMonthRecords():void
    var sqlText:String = &quot;INSERT INTO month( monthname)
    &quot; +
    &quot;VALUES('Januari')&quot;;
    insertStatement = new SQLStatement();
    insertStatement.sqlConnection = conn;
    insertStatement.addEventListener(SQLEvent.RESULT,
    insertResult);
    insertStatement.addEventListener(SQLErrorEvent.ERROR,
    errorHandler);
    insertStatement.text = sqlText;
    insertStatement.execute();
    insertStatement.text = &quot;INSERT INTO month(monthname)
    VALUES('Februari')&quot;;
    insertStatement.execute();
    insertStatement.text = &quot;INSERT INTO month(monthname)
    VALUES('March')&quot;;
    insertStatement.execute();
    insertStatement.text = &quot;INSERT INTO month(monthname)
    VALUES('April')&quot;;
    insertStatement.execute();
    And so on.. To bad i didn't found a solution to execute all
    the inserts at once. Inserting this way takes time :-(
    If you have a better solution, just let me know.
    Greetz, Jacob

  • Multiple rows insert and update form example

    I just want to share with you an example of a multiple rows insert and update form. You can access it HERE (http://tryapexnow.com/apex/f?p=12090:21)
    You will find on the same page the complete description of all elements used to buid it.
    I'm waiting for opinions, suggestions, and questions here in this thread.
    Thanks

    Hello Valentin,
    I got an error message when I clicked on the weblink. Here is the message
    Error ERR-7620 Could not determine workspace for application. Could you please take a look at this.
    Thanks,
    Karol

  • Multiple DB inserts for 1 Submit

    Hello,
    We're running CFMX 6.1 on Win2003 Servers with Oracle 8.0.3
    DB on UNIX.
    We have free projects available on our website in exchange
    for a consumer signing up for our email
    newsletter. Somewhere along the way between almost 2 years
    ago and just recently I made some kind
    of change that is allowing duplicate email names to be
    entered although the CFQUERY is supposed to
    check to see if the email_address is already in the database.
    The weird thing is that I see the
    time of creation is so close together that it seems like the
    consumer couldn't have clicked the
    submit button that many times so quickly, for example:
    EMAIL_NEWS_LIST_ID EMAIL_ADD TO_CHAR(DATE
    150382 [email protected] 15:40:39 PM
    150383 [email protected] 15:40:40 PM
    150384 [email protected] 15:40:42 PM
    150385 [email protected] 15:40:41 PM
    150386 [email protected] 15:40:47 PM
    When I just go to the page on my website and try to access
    the project by giving it my email address
    it does the right thing which is to check that I'm in the DB
    and since I am already there it does
    not add me again but just puts the cookie on my machine so
    that I can view the projects. The code
    checks to see if the email_add is in the DB already and is
    NOT supposed to enter it again but just
    CFLOCATE them to the page they want to view.
    Here is my CF code:
    <cfset date_created = CreateODBCDateTime(now())>
    <!--- first check to see if the emailAdd from the form is
    in the DB --->
    <cfif IsDefined("Form.emailAdd")>
    <cfset email_Add=Lcase(Form.emailAdd)>
    <cfquery datasource="#secondaryDS#" name="checkEmail">
    select email_news_list_id, email_add
    from email_list
    where lower(email_add)=lower('#Form.emailAdd#')
    </cfquery>
    </cfif>
    <!--- if emailAdd is in DB set status to 1 and cflocate to
    page --->
    <cfif Form.emailAdd EQ checkEmail.email_add>
    <cfcookie name="inEmailList" value="Y"
    expires="never">
    <cflocation
    url="index.cfm?page=section/classroom/sewprojects/EraBonnet/eraBonnet.
    cfm">
    <cfelse>
    <!--- otherwise set emailStatus to 2 and add to DB, this
    will trigger proper message below
    --->
    <cfset email_Add = "#Form.emailAdd#">
    <cftransaction>
    <cfquery name="addToEmailList"
    datasource="#secondaryDS#">
    <!--- this selects the email_news_list_id from a next_key
    table --->
    declare nk int;
    begin
    update next_key
    set next_key = next_key + 1
    where table_name = 'email_list';
    select next_key + 1 into nk
    from next_key
    where table_name = 'email_list';
    insert into email_list(
    email_news_list_id,
    email_add,
    first_name,
    last_name,
    spanish_lang,
    date_created,
    promo_code
    values(
    nk,
    '#Lcase(email_add)#',
    '#first_name#',
    '#last_name#',
    '1',
    #date_created#,
    #promo_code#
    end;
    </cfquery>
    </cftransaction>
    <cfcookie name="inEmailList" value="Y"
    expires="never">
    <!-- Run email reply -->
    <cfmail from="[email protected]" to="#email_Add#"
    subject="Anonymous Co." server=
    "#WEBMAIL_EMAIL_SERVER#">
    Hello #email_Add#
    Welcome to our newsletter.
    </cfmail>
    <cflocation
    url="index.cfm?page=section/classroom/sewprojects/EraBonnet/eraBonnet.cfm"
    addtoken=
    "no">
    </cfif>
    The major sticking point is that I don't understand HOW and
    WHY this is happening. I have tens of
    thousands of email addresses where - at least by the naked
    eye - it appears that I don't have any
    doubles. Yet starting around August 21, 2006 these duplicates
    are multiplying. Due to my lack of
    organization - and not always using custom tags - some of the
    code pages as presented above are
    duplicates whereas the newer ones are using the custom tags.
    Regardless, it appears that I am
    getting multiple entries for the same submit.
    I cannot really change the underlying database table because
    it's used to support another
    application (Campaign8) that has it's own requirements which
    are met by the current table.
    Thanks much,
    Jerry

    Sorry about that I forgot to mention one other detail. On the
    topic of "list" what I meant was is that
    there are no Itemdetails that have "selectable values" (ie
    can't have more than one value per
    itemdetail) in a multiselect box. The sql pulls up all the
    itemdetails assigned to that person (for that
    item) and all the values for those item details (one value
    per itemdetail).
    What I need is an insert statement that will perform multiple
    inserts using information retrieved from
    other queries. The information input into the textboxs by
    users will also be used to fill in one of the
    fields (NewItemValue) while the 3 remaining fields (ItemID,
    ItemDetailID, ActionItemID) will be filled in
    from data from other queries. Here's an example query I'm
    working with.
    <cfif isdefined "Submit>
    <cfquery name ="ItemDetailInsert>
    Insert Into ItemDetailUpdates (ItemID, ItemDetailID,
    NewItemValue, ActionItemID)
    Values (#queryA.ItemID#, #queryA.ItemDetailID#,
    #form.NewItemValue#ID##,
    #queryB.ActionItemID#)
    </cfquery>
    My question here is: Will this query work as it is now? I
    want this query to do multiple inserts so should I put this query
    in a cfloop? or will the query automatically know to keep inserting
    data until their is no data left to insert?Any help would be
    appreciated.
    Thanks again for all your help.

  • Multiple Checkbox Insert Handling

    Every so often, I need to refresh my knowledge regarding how to handle multiple check box selections, and how they get handled on an action page to insert correctly in a DB.
    In a helpdesk application, the admin assigns projects to technicians. He may assign one project to several technicians.
    The first action page inserts the data from the form into the DB with time and date stamps, due dates, etc.
    Here is where the selected checkboxes do not get passed.
    The second action page depends on the fist, populating a junction table using:
    <cfquery name="get_project_ID" datasource="#Request.BaseDSN#">
       SELECT MAX (project_ID) as lastID
       FROM main_projects
    </cfquery>
        <cfloop index="i" list="#tech_ID#">
            <cfquery name="TheQuery" datasource="#Request.BaseDSN#">
                INSERT
                INTO     junction_project_tech
                        (junc_tech_ID, junc_project_ID)
                VALUES     (
                            <cfqueryparam cfsqltype="cf_sql_integer" value="#i#">,
                            #get_project_ID.lastID#
            </cfquery>
        </cfloop>
    Any help would be greatly appriciated-
    newportweb

    Thanks for your quick reponse. I hope you don't cringe easily...
    1 form:
    <cfquery name="get_tech" datasource="#Request.BaseDSN#">
    SELECT *
    FROM lookup_tech
    </cfquery>   
    <form action="project_action.cfm" method="post">
    <p><strong>Description:</strong></p>
    <p><textarea cols="120" rows="10" name="project_desc" wrap="hard" class="inputtext"></textarea></p>
    <p><strong>Assigned Technicians</strong></p>
    <cfoutput query="get_tech">
        <tr>
    <td width="75%" class="tddynamic">#tech_lname# <div class="sbfield"><strong>Due Date:</strong> <input type="text" name="due_date" size="8" class="sbfield"> </td>
    <td width="25%" class="tddynamic"><INPUT Type="Checkbox" Name="tech_ID" Value="#tech_ID#"</td>
    </tr>
    </cfoutput>
    <cfoutput>
    <input type="hidden" name="assign_date" value="#DateFormat(CreateODBCDate(Now()), "mm/dd/yyyy")#">
    <input type="hidden" name="assign_time" value="#TimeFormat(CreateODBCTime(Now()), "hh:mm tt")#"></cfoutput>
    <input type="submit" name="" value="Submit Project" class="formbutton">
    </td>
    </tr></form>
    Action1
    <CFPARAM Name="tech_ID" Default=0>
    <cfquery name="create_project" datasource="#Request.BaseDSN#">
    INSERT INTO main_projects (
    project_desc,
    assigned,
    assign_date,
    assign_time,
    due_date,
    assigned_tech1,
    assigned_tech2,
    assigned_tech3,
    assigned_tech4,
    tech_1_hours,
    tech_2_hours,
    tech_3_hours,
    tech_4_hours
    VALUES  (
    '#project_desc#',
    1,
    '#Form.assign_date#',
    '#Form.assign_time#',
    '#FORM.due_date#',
    (insert checkbox values from form here),
    0,
    0,
    0,
    0
    )</cfquery>
    <cflocation url="project_action2.cfm?tech_ID=#Form.tech_ID#" addtoken="No">
    Action2: You have seen.
    DB: MS Access- I know, I know. I'm getting to SQL Server soon.
    Thanks again....

  • Multiple rows insertion - need help

    Hello all,
    I need to insert multiple rows in a table with a single query and the number of rows is 269470.
    There are 3 columns in the table. One of the columns is determined by another sub query which returns multilple(269470) rows and the other 2 columns remain same for all.
    I came up with the following query but need a loop to make it run multiple time(269470 times).
    insert into EMLUSRRECV
    (user_id, storeent_id, receiveml)
    values
    ((select user_id from users where user_id not in (select distinct user_id from EMLUSRRECV) and CURR = 'USD' and rownum = 1), 11154, 1);
    Thanks in advance.
    Edited by: 924585 on Feb 20, 2013 7:19 PM

    924585 wrote:
    Hello all,
    I need to insert multiple rows in a table with a single query and the number of rows is 269470.
    There are 3 columns in the table. One of the columns is determined by another sub query which returns multilple(269470) rows and the other 2 columns remain same for all.
    I came up with the following query but need a loop to make it run multiple time(269470 times).
    insert into EMLUSRRECV
    (user_id, storeent_id, receiveml)
    values
    ((select user_id from users where user_id not in (select distinct user_id from EMLUSRRECV) and CURR = 'USD' and rownum = 1), 11154, 1);
    Thanks in advance.
    Edited by: 924585 on Feb 20, 2013 7:19 PMwhy not just:
    insert into emlusrrecv
    select user_id, 11154, 1
      from  users
    where user_id not in (select user_id from EMLUSRRECV)
    and CURR = 'USD' and rownum = 1)

  • Xsql multiple table insert

    I'm having trouble getting my xml document inserted into multiple tables. My xml has a parent child relationship. The main node is the parent I'll call <CAKE> then later on in the xml doc it has a node called <INGREDIENTS> which is a repeating element (more than 1). I need to insert information from the root node, <CAKE> into 1 table and all the info from <INGREDIENTS> node into another table.
    I've tried to get Steve Muench's book a try (chapter 14) but when I try to run the examples from the book (XMLLoader) i get the following error.
    C:\jdev9i\jdk1.3\bin\javaw.exe -ojvm -classpath C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14\classes;C:\oracle\ora81\RDBMS\jlib\xsu12.jar;C:\jdev9i\lib\xmlparserv2.jar;C:\jdev9i\jdev\lib\jdev-rt.jar;C:\jdev9i\jdbc\lib\classes12.jar;C:\jdev9i\jdbc\lib\nls_charset12.jar;C:\jdev9i\jlib\jdev-cm.jar;C:\jdev9i\rdbms\jlib\xsu12.jar;C:\jdev9i\lib\xmlparserv2.jar;C:\jdev9i\lib\xmlcomp.jar;C:\jdev9i\lib\oraclexsql.jar;C:\jdev9i\rdbms\jlib\xsu12.jar;C:\jdev9i\lib\xsqlserializers.jar;C:\jdev9i\lib\xmlparserv2.jar;C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14\classes;C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14\classes;C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14\classes -
    mx50m
    XMLLoader -file deptempdepend.xml -transform deptempdepend.xsl
    Processed 1 Documents
    Node doesn't belong to the current document.
    Error: java.lang.NullPointerException
    Process exited with exit code 0.

    I made the changes in the java files as per the previous
    reference, but I'm still getting an error. Seeing that I'm not
    much of a Java guy yet, I'm not sure where to debug the error.
    So here it is:
    XMLLoader -file deptempdepend.xml -transform deptempdepend.xsl
    Processed 1 Documents
    null
    Error: java.lang.NullPointerException
    Process exited with exit code 0.
    I tried to debug it and came to the conclusion that it is
    failing at line 22 of ConnectionFactory
    The value connNode is returend as null.
    I don't understand why:
    I ran testxpath.exe for the connections file.
    C:\jdev9i\jdev\mywork\orxmlapp\Examples\ch14>testxpath connections.xml
    Type an XPath expression to test and press [Enter]
    To quit, press [Enter] without entering a path.
    connections.xml> /connections/connection[@name='doug']
    <connection name="doug">
    <username>user</username>
    <password>password</password>
    <dburl>jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=
    (ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))
    (CONNECT_DATA=(SERVICE_NAME=dtxml.hmms)))</dburl>
    <driver>oracle.jdbc.driver.OracleDriver</driver>
    </connection>
    connections.xml>
    and it returned what i thought would be the correct nodes.
    Any help would be appreciated
    Doug

  • List/Menu (multiple selected)  insert into MySQL

    I have been building a feedback form and I am running into a
    issue that when I place a list/menu that allows multiple selections
    when I submit my form in my MySQL database it collected the
    information but only on the last multiple selection.
    For example, this is what my list/menu looks like.
    <select name="occasion" size="5" multiple="MULTIPLE"
    id="occasion">
    <option value="Spur of the moment,">Spur of the
    moment</option>
    <option value="Family dinner">Family
    dinner</option>
    <option value="Special occasion (i.e.
    birthday)">Special occasion (i.e. birthday)</option>
    <option value="Office get together">Office get
    together</option>
    <option value="Romantic dinner">Romantic
    dinner</option>
    <option value="Night out with friends">Night out with
    friends</option>
    <option value="Business meeting">Business
    meeting</option>
    <option value="Other">Other</option>
    </select>
    And my MySQL database I have it set up as...
    Field Type
    occasion mediumtext
    I do not know why I cannot have more than one selection
    inputed into my field, what must I do to correct this? Everything
    works perfectly expect the multi selected list/menu. I want to
    place all that is selected in the list/menu in that one database
    field called occasion.

    .oO(MikeL7)
    >>You should also test with isset() and is_array() if
    $_POST['occasion']
    >>is available at all and of the expected type. The
    code above will also
    >>throw a notice if $insert_string is not initialized
    before the loop.
    >
    > I use both isset and is_array in my code, When you say
    notice, you dont mean
    >a script stoppiong error?
    Nope. An E_NOTICE error won't terminate the script, but
    shouldn't happen
    nevertheless. While developing, the error_reporting directive
    should be
    set to E_ALL|E_STRICT and _all_ reported problems should be
    solved. It's
    not only better coding style, but also helps to prevent real
    errors. In
    this particular case it was just a guess, because it was only
    a part of
    the code. But using an uninitialized variable with a '.='
    operator for
    example would lead to a notice, which should be fixed.
    >>But of course this is a really bad DB design, as it
    already violates the
    >> first normal form (1NF). Just some ideas for queries
    that might come to
    >> mind, but would be really hard to do with such a
    comma-separated list:
    >
    > A better table design would be to have column for |
    list_ID | user_ID |
    >song_ID | and do a insert for each song selected.
    Yes, something like that.
    >Thanks for the input, i like escaping the variables from
    a string as they
    >stand out more in code view, is the single quote method
    faster? And which one
    >will be or is already deprecated?
    All are correct and won't be deprecated. IMHO it's more or
    less just
    personal preference. It also depends on the used editor and
    its syntax
    highlighting capabilities. For example I use Eclipse/PDT for
    all my PHP
    scripts, which can also highlight variables inside a string.
    But if the
    above is your preferred way, there's nothing really wrong
    with it.
    Just some additional thoughts:
    Personally I prefer as less escaping and concatenating as
    possible,
    because such a mixture of single quotes, double quotes, dots
    and
    sometimes even escaped quote signs (for example when printing
    HTML)
    _really_ confuses me. I like to keep my code clean and
    readable.
    Something like this:
    print "<img src=\"".$someVar."\" ...>\n";
    not only hurts my eye, it is also quite error-prone. It's
    easy to miss a
    quote or a backslash and get a parse error back, especially
    in editors
    with limited syntax highlighting (or none at all). So I would
    prefer
    print "<img src='$someVar' ...>\n";
    or even
    printf("<img src='%s' ...>\n", $someVar);
    When it comes to performance issues, of course there's a
    difference
    between the various methods. But for me they don't really
    matter. In
    practice you usually won't notice any difference between an
    echo, a
    print or a printf() call for example, as long as you don't
    call them
    a million times in a loop.
    So I always just use the method that leads to the most
    readable code.
    In many cases, especially when a lot of variables or
    expressions are
    involved, (s)printf() wins. Not for performance, but for
    readability.
    But as said - personal preference. YMMV.
    Micha

  • SQL Server 2008 - RS - Loop of multiple Bulk Inserts

    Hi,
    I want to import multiple flat files to a table on SQL Server 2008 R2. However, I don't have access to Integration Services to use a foreach loop, so I'm doing the process using T-SQL. Actually, I'm using manually code to which file to introduce the data on
    tables. My code are like this:
    cREATE TABLE #temporaryTable
        [column1] [varchar](100) NOT NULL,
        [column2 [varchar](100) NOT NULL
    BULK
    INSERT #temp
    FROM 'C:\Teste\testeFile01.txt' 
    WITH
    FIELDTERMINATOR = ';',
    ROWTERMINATOR = '\n',
    FIRSTROW = 1
    GO
    BULK
    INSERT #temp
    FROM 'C:\Teste\testeFile02.txt' 
    WITH
    FIELDTERMINATOR = ';',
    ROWTERMINATOR = '\n',
    FIRSTROW = 1
    GO
    -------------------------------------------------INSERT INTO dbo.TESTE ( Col_1, Col_2)
    Select RTRIM(LTRIM([column1])), RTRIM(LTRIM([column2])) From #temporaryTable
    IF EXISTS(SELECT * FROM #temporaryTable) drop table #temporaryTable
    The problem is that I have 20 flat files to Insert... Do I have any loop solution in T-SQL to insert all the flat files on same table?
    Thanks!

    Here is a working sample of powershell script I adopted from internet( I don't have the source handy now).
    Import-Module -Name 'SQLPS' -DisableNameChecking
    $workdir="C:\temp\test\"
    $svrname = "MC\MySQL2014"
    Try
    #Change default timeout time from 600 to unlimited
    $svr = new-object ('Microsoft.SqlServer.Management.Smo.Server') $svrname
    $svr.ConnectionContext.StatementTimeout = 0
    $table="test1.dbo.myRegions"
    #remove the filename column in the target table
    $q1 = @"
    Use test1;
    IF COL_LENGTH('dbo.myRegions','filename') IS NOT NULL
    BEGIN
    ALTER TABLE test1.dbo.myRegions DROP COLUMN filename;
    END
    Invoke-Sqlcmd -ServerInstance $svr.Name -Database master -Query $q1
    $dt = (get-date).ToString("yyyMMdd")
    $formatfilename="$($table)_$($dt).xml"
    $destination_formatfilename ="$($workdir)$($formatfilename)"
    $cmdformatfile="bcp $table format nul -c -x -f $($destination_formatfilename) -T -t\t -S $($svrname) "
    Invoke-Expression $cmdformatfile
    #Delay 1 second
    Start-Sleep -s 1
    $q2 = @"
    Alter table test1.dbo.myRegions Add filename varchar(500) Null;
    #add the filename column to the target table
    Invoke-Sqlcmd -ServerInstance $svr.Name -Database master -Query $q2
    $files = Get-ChildItem $workdir
    $items = $files | Where-Object {$_.Extension -eq ".txt"}
    for ($i=0; $i -lt $items.Count; $i++) {
    $strFileName = $items[$i].Name
    $strFileNameNoExtension= $items[$i].BaseName
    $query = @"
    BULK INSERT test1.dbo.myRegions from '$($workdir)$($strFileName)' WITH (FIELDTERMINATOR = '\t', FIRSTROW = 2, FORMATFILE = '$($destination_formatfilename)');
    Invoke-Sqlcmd -ServerInstance $svr.Name -Database master -Query $query -querytimeout 65534
    #Delay 10 second
    Start-Sleep -s 10
    # Update the filename column
    Invoke-Sqlcmd -ServerInstance $svr.Name -Database master -querytimeout 65534 -Query "Update test1.dbo.myRegions SET filename= '$($strFileName)' WHERE filename is null; "
    # Move uploaded file to archive
    If ((Test-Path "$($workdir)$($strFileName)") -eq $True) { Move-Item -Path "$($workdir)$($strFileName)" -Destination "$($workdir)Processed\$($strFileNameNoExtension)_$($dt).txt"}
    Catch [Exception]
    write-host "--$strFileName "$_.Exception.Message

  • Multiple SQLs INSERT in a single SQL with O.Lite on PDA

    Hi,
    We are using(and new to) Oracle on PDA, dvlping in JAVA. We need to increase performance and reliability to make multiple INSERT in a single SQL statement, dynamically created :
    We've got a syntax error when executing this :
    INSERT INTO t1 (row1,row2) VALUES ('x','y');
    INSERT INTO t1 (row1,row2) VALUES ('a','v');
    INSERT INTO t1 (row1,row2) VALUES ('e','r');
    etc... in a single execSql
    Any suggests would be helpfull !
    JMarc
    [email protected]

    Hi Praveen
    If your use case is like having large no. of data rows and inserting those into DB. I believe best appropriate way would be form a xml and then pass it to DB. While in DB, you can create SP and perform your logical steps(if any) thereafter inserting data into table.
    The above link shared by Muzammil talks on the same subject.
    While once within SP(DB layer), you can fetch entire xml using below example:
    DECLARE @data XML;
    -- Element-centered XML
    SET @data = '<data>
        <customer>
          <id>1</id>
          <name>Name 1 </name>
        </customer>
        <customer>
          <id>2</id>
          <name>Name 2</name>
        </customer>
         <customer>
          <id>3</id>
          <name>Name 3</name>
        </customer>  
        </data>';
    SELECT T.customer.value('(id)[1]', 'INT') AS customer_id,
           T.customer.value('(name)[1]', 'VARCHAR(20)') AS customer_name
    FROM @data.nodes('data/customer') AS T(customer);
    The above run will give you output from xml in single shot.
    You can also find maximum no. of rows as below.
    declare @max int
    select @max = @data.value('fn:count(/data/customer/id)','int')
    select @max  
    I believe above should help you around with your insertion...

  • MULTIPLE UPDATES/INSERTIONS TO THE SAME TABLE

    How can I update/insert mutiple rows into the same table from one form ?

    Hi,
    Using the portal form on table you can insert only a single row. You can use master-detail form to insert multiple rows.
    Thanks,
    Sharmila

  • Alv report for multiple record insertion

    hi,
    i'm new to abap. i'm using alv report for record display and insertion. how can i insert multiple records from alv to my table??

    well that can be achieved only by running BDC inside alv report to enter the entries.and in that too you can append or edit single entries only
    reward if useful
    regards
    vivek

  • RFC to JDBC Scenario: Multiple Records insertion

    Hi All,
    I am working with RFC->XI->JDBC to update a single table on an Oracle db.
    When I import RFC I get multiple Records.
    Here is the sender XML Structure:
      <?xml version="1.0" encoding="UTF-8" ?>
    - <rfc:Z_I2_SAP2MDM_VM xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
    + <I_LFA1>
      </I_LFA1>
      <T_XLFAT />
    - <T_XWYT3>
    - <item>
      <MANDT>800</MANDT>
      <LIFNR>0000009962</LIFNR>
      <EKORG>1000</EKORG>
      <LTSNR />
      <WERKS />
      <PARVW>LF</PARVW>
      <PARZA>000</PARZA>
      <ERNAM>ARUCHI</ERNAM>
      <ERDAT>2006-05-26</ERDAT>
      <LIFN2>0000009962</LIFN2>
      <DEFPA />
      <PERNR>00000000</PERNR>
      <PARNR>0000000000</PARNR>
      <KZ>I</KZ>
      </item>
    - <item>
      <MANDT>800</MANDT>
      <LIFNR>0000009962</LIFNR>
      <EKORG>1000</EKORG>
      <LTSNR />
      <WERKS />
      <PARVW>RS</PARVW>
      <PARZA>001</PARZA>
      <ERNAM>ARUCHI</ERNAM>
      <ERDAT>2006-05-26</ERDAT>
      <LIFN2>0000009962</LIFN2>
      <DEFPA />
      <PERNR>00000000</PERNR>
      <PARNR>0000000000</PARNR>
      <KZ>I</KZ>
      </item>
      </T_XWYT3>
      </rfc:Z_I2_SAP2MDM_VM>
    It takes only the first <item> record. How do i take the second record and insert in the oracel DB.
    Seems to me this should be a pretty simple process.
    Regards,
    Ruchi

    Hi ,
    You need to handle  this with the occurence of the Target Structure of the JDBC Adapter..
    Check this help-
    http://help.sap.com/saphelp_nw2004s/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
    DB Datatype structure ?
    Hope this helps,
    Regards,
    Moorthy

Maybe you are looking for