ColdFusion如何使用cfloop更新多个记录

时间:2016-03-24 21:42:40

标签: coldfusion-10

我需要帮助使用cfloop更新多条记录 -

更新声明

<cfloop list="#form.id#" index="id">
      <cfquery name="Qname" datasource="#datasourceName#" >
        UPDATE TABLENAME
        SET timeIN = <cfqueryparam  value="#('form.timeIN_' & id)#"  cfsqltype="CF_SQL_TIME" maxlength="8">,
        timeOUT = <cfqueryparam  value="#('form.timeOUT_' & id)#"  cfsqltype="CF_SQL_TIME" maxlength="8">,  
        dWeek= <cfqueryparam  value="#('form.dWeek_' & id)#"  cfsqltype="CF_SQL_VARCHAR" maxlength="3">,  
        label = <cfqueryparam  value="#('form.label_' & id)#"  cfsqltype="CF_SQL_VARCHAR" maxlength="10">
        WHERE id =#id#   
    </cfquery>
 </cfloop>
  

查询结果

    schedule_ID     timeOUT ID  label   timeIN  dWeek
1   8   09:00 PM    147     BREAKFAST   07:30:00    MON
2   8   09:00 PM    148     BREAKFAST   07:30:00    TUE
3   8   09:00 PM    149     BREAKFAST   07:30:00    WED
4   8   09:00 PM    150     BREAKFAST   07:30:00    THU
5   8   06:00 PM    151     BREAKFAST   07:30:00    FRI
6   8   06:00 PM    152     BREAKFAST   07:30:00    SAT
7   8   06:00 AM    153     BREAKFAST   07:30:00    SUN

表单转储

FIELDNAMES ID,dWeek_147,label_147,timeIN_147,timeOUT_147,dWeek_148,label_148,timeIN_148,timeOUT_148,dWeek_149,label_149,timeIN_149,timeOUT_149,dWeek_150,label_150,timeIN_150,timeOUT_150,dWeek_151,label_151,timeIN_151 ,timeOUT_151,dWeek_152,label_152,timeIN_152,timeOUT_152,dWeek_153,label_153,timeIN_153,timeOUT_153,UPDATE

----------

ID  147,148,149,150,151,152,153
----------

timeIN_147  07:30:00
timeIN_148  07:30:00
timeIN_149  07:30:00
timeIN_150  07:30:00
timeIN_151  07:30:00
timeIN_152  07:30:00
timeIN_153  09:30:00

----------

timeOUT_147     09:00:00
timeOUT_148     09:00:00
timeOUT_149     09:00:00
timeOUT_150     09:00:00
timeOUT_151     06:00:00
timeOUT_152     06:00:00
timeOUT_153     06:00:00

----------

dWeek_147   MON
dWeek_148   TUE
dWeek_149   WED
dWeek_150   THU
dWeek_151   FRI
dWeek_152   SAT
dWeek_153   SUN

----------

label_147   BREAKFAST
label_148   BREAKFAST
label_149   BREAKFAST
label_150   BREAKFAST
label_151   BREAKFAST
label_152   BREAKFAST
label_153   BREAKFAST

0 个答案:

没有答案