Hi Everyone,

Got a bit of a dilema :

I have a table for user details  with a field schedule_num which contains
the total number of forms filled out by a person.

I have another table for the forms. This has a field with the users user_id
and  with the field schedule_id which is supposed to contain a counting
number for each form. Now schedule_id is a unique number but I don't want
to use autonumbering for it. This is because when a user wants to see their
forms they should only see the numbers 1 to schedule_num with their forms
and not a autonumbered 20324.

Now someone has gone and wiped the schedule_id field from my forms table
and rather than hand code all 3000 records I was wondering if there was
anyway I could get the schedule_num from user_details for each user and
then loop from 1 to schedule_num updating the forms table's schedule_id so
that I had my schedule_id's back.
So basically If the user has 5 forms
Name :         User_id :
 Form1          1
Form2           1
Form3           1
Form4           1
Form5           1
(generic names used)
How can I make it look like :

Name:          User_id:  Schedule_id:
Form1          1         1
Form2          1         2
Form3          1         3
Form4          1         4
Form5          1         5

I have tried my hand at the code, but the loops are too long and the
browser times out.

<cfquery name="qGetSchedID" datasource="RTRE">
SELECT user_id, schedule_num
FROM User_details
WHERE schedule_num > 0
</cfquery>

<cfoutput query="qGetSchedID">

<cfloop index="i" from="1" to="#qGetSchedID" step="1">

<cfquery name="qUpdateWrksSched" datasource="RTRE">
Update works_schedule
SET schedule_id = #i#
WHERE user_id = #qGetSchedID.user_id#
</cfquery>

</cfloop>

</cfoutput>

Any help appreciated.


Thanks,
Kunal Bhatia
__________________________________________________
Web Programmer
CSC
Ph: 02 6246 8715    Mobile: 0411022234    Email: [EMAIL PROTECTED]


Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to