Thx for all who wrote.

It works now. (I'm using Access2000)

RE: The CreateODBCDate.

    It works well. Thx. I didn't think it was necessary. Combining fields in
the SQL usually works well but this seems much better in this case.

RE: cftransaction / cftry / cfcatch -- thx, I see why it's necessary.

RE: looping the list of dates

right now I have:

<cfset
date1=#DateFormat(CreateODBCDate(createdate(form.year1,form.month1,form.day1
)),"mm/dd/yyyy")#>
<cfset
date2=#DateFormat(CreateODBCDate(createdate(form.year2,form.month2,form.day2
)),"mm/dd/yyyy")#>
<cfset
date3=#DateFormat(CreateODBCDate(createdate(form.year3,form.month3,form.day3
)),"mm/dd/yyyy")#>
<cfset
date4=#DateFormat(CreateODBCDate(createdate(form.year4,form.month4,form.day4
)),"mm/dd/yyyy")#>

<cfset dateList="#date1#,#date2#,#date3#,#date4#">

It works, but is very inelegant.

How would one loop through the above?

you can't do a

<cfloop from="1" to="4" index="myIndex">

<cfset date#myIndex#= ...form.year#myIndex#,form.month#myIndex# ...>

</cfloop>

so what would one do it if there were 10 inserts or 50?

Gil
  -----Original Message-----
  From: Pete Ruckelshaus [mailto:[EMAIL PROTECTED]
  Sent: Monday, October 13, 2003 3:16 PM
  To: CF-Talk
  Subject: Re: multiple inserts, no solution

  You didn't mention what DB you are using.  I have done exactly this on
Oracle, using the following code:

  <cfquery name="FaveItems" datasource="#request.app.dsn#">
  INSERT INTO  tr_gui_favorites
  SELECT    <cfqueryparam cfsqltype="CF_SQL_NUMERIC"
value="#REQUEST.CFA.REQUESTOR_ID#">, <cfqueryparam
cfsqltype="CF_SQL_VARCHAR" value="#type_cd#">, column_value FROM
     (
      SELECT column_value from TABLE (cast(numTableType(<cfqueryparam
cfsqltype="CF_SQL_VARCHAR" list="Yes" value="#FaveItems#" separator=",">) as
numTableType))
     )
  </cfquery>

  Obviously, you'll need to make changes to this, but it might require
firing the neurons up a bit.

  Pete
    ----- Original Message -----
    From: mayo
    To: CF-Talk
    Sent: Monday, October 13, 2003 10:52 AM
    Subject: multiple inserts, no solution

    BACKGROUND INFO:

    I'm creating an admin form allowing a user to enter class schedules.

    Class Title, Class Description, Class Time, Class Price are all simple
    inserts.

    The problem comes in when entering the class dates. There are sometimes
one
    class, sometimes two, four or six. Often times they will be one week
apart,
    but not always.

    example: Class 1 will meet at 2PM on Tuesday the 1st, the 8th, the 15th,
the
    22nd.

    The admin page allows the user to put in the dates desired by clicking
on
    the appropriate calendar day.

    PROBLEM:

    One "click" should allow the user to input 2 or more class dates.

    A straight loop <cfloop from="1" to="#classQty#"> tries to input
multiple
    class days into the classDate field.

    example of error below:

    INSERT INTO classDates
    ( classID, classDay, classSession, classDates, classTime )
    VALUES ( '5', 'Mon', '1', '2003,2003,2003,2003/10,10,10,10/1,8,15,22',
    '12:00-2:00' )

    SOLUTION ???:

    I had thought that I could do something like the following

    <cfoutput>
    <cfloop from="1" to="#FORM.number#" index="getClassDate">
    <cfset

date=#FORM.month##getClassDate#&"/"&#FORM.day1##getClassDate#&"/"&#FORM.year
    1##getClassDate#>

    <cfquery name="" datasource="">

    INSERT INTO classDates
    (
    classID,
    classDay,
    classSession,
    classDates,
    classTime
    )
    VALUES
    (
    '#FORM.classID#',
    '#FORM.classDay#',
    '#FORM.classSession#',
    '#date#',
    '#FORM.classTime#'
    )

    </cfquery>
    </cfloop>
    </cfoutput>

    I see why it doesn't work. So, how does one do multiple inserts of this
    kind?

    Gilbert Midonnet



[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to