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