I need help doing a loop over the following recordsets to insert into another table. Hopefully the code/markup will explain it better.
<!--- select all kits associated with a service instruction from the form --->
<cfquery name="getKits" datasource="#dsn#">
SELECT kit
FROM ACFT_KIT
WHERE SERV_INSTR = '#form.mySERV_INSTR#'
ORDER BY kit
</cfquery>
<!---If this is first requisition posted today reset counter table to reflect todays date and start serial number at 1--->
<cfquery name="updSERNO" datasource="#dsn#">
update serno_ctr
set serno = '1',
upd_date = to_char(sysdate, 'dd-mon-yyyy')
where upd_date != to_char(sysdate, 'dd-mon-yyyy')
</cfquery>
<!---Select the serial number from counter table--->
<cfquery name="nexSerno" datasource="#dsn#">
SELECT serno
FROM serno_ctr
</cfquery>
<!---Increment the serial number--->
<cfset nextSERNO = #nexSerno.serno# + 1>
<!---
This is where I need the help. I need to loop over the INSERT query to insert seperate records for each kit retrieved in the getKits query and increment the serno for each new record with a final UPDATE query into the serno table with the last records serial number. The basic query if there were only one kit would look like this
--->
<cfquery name="insKITS" datasource="pbl_tracking">
INSERT INTO ACFT_PARTS_TBL (JDATE, PBL_CD, MATL_TYPE, BUNO, JON, SERV_INSTR, PROJECT, UNIT, QTY, DROP_LOCATION, PART_NO, serno)
VALUES('#form.jdate#', 'BV', 'KIT', '#form.myBUNO#', '#getJON.myJON#', '#form.mySERV_INSTR#', '#getJON.myPROJECT#', 'EA', '1', 'STA9', '#getKits.kit#', '#nextSERNO#')
</cfquery>
<!---only one record is in the serno table, no need to use where--->
<cfquery name="updSERNO" datasource="#dsn#">
update serno_ctr
set serno = '#nextSERNO#'
</cfquery>
Thanks for your help.
Dave
<!--- select all kits associated with a service instruction from the form --->
<cfquery name="getKits" datasource="#dsn#">
SELECT kit
FROM ACFT_KIT
WHERE SERV_INSTR = '#form.mySERV_INSTR#'
ORDER BY kit
</cfquery>
<!---If this is first requisition posted today reset counter table to reflect todays date and start serial number at 1--->
<cfquery name="updSERNO" datasource="#dsn#">
update serno_ctr
set serno = '1',
upd_date = to_char(sysdate, 'dd-mon-yyyy')
where upd_date != to_char(sysdate, 'dd-mon-yyyy')
</cfquery>
<!---Select the serial number from counter table--->
<cfquery name="nexSerno" datasource="#dsn#">
SELECT serno
FROM serno_ctr
</cfquery>
<!---Increment the serial number--->
<cfset nextSERNO = #nexSerno.serno# + 1>
<!---
This is where I need the help. I need to loop over the INSERT query to insert seperate records for each kit retrieved in the getKits query and increment the serno for each new record with a final UPDATE query into the serno table with the last records serial number. The basic query if there were only one kit would look like this
--->
<cfquery name="insKITS" datasource="pbl_tracking">
INSERT INTO ACFT_PARTS_TBL (JDATE, PBL_CD, MATL_TYPE, BUNO, JON, SERV_INSTR, PROJECT, UNIT, QTY, DROP_LOCATION, PART_NO, serno)
VALUES('#form.jdate#', 'BV', 'KIT', '#form.myBUNO#', '#getJON.myJON#', '#form.mySERV_INSTR#', '#getJON.myPROJECT#', 'EA', '1', 'STA9', '#getKits.kit#', '#nextSERNO#')
</cfquery>
<!---only one record is in the serno table, no need to use where--->
<cfquery name="updSERNO" datasource="#dsn#">
update serno_ctr
set serno = '#nextSERNO#'
</cfquery>
Thanks for your help.
Dave