Get ready for BLACK FRIDAY shopping starting in

Forums

This topic is locked

INSERT MUTLIPLE RECORDS FROM PASSED FORM VARIABLES

Posted 15 Aug 2006 22:05:47
1
has voted
15 Aug 2006 22:05:47 Zenny Sadlon posted:
Istarted with this:

<cfquery name="Nominee" datasource="EmployeeAwards">
INSERT INTO AnnualAwards
(<EmployeeID, Region, Division, FirstName, MiddleName, LastName, GroupAward, AwardYear, Award, AwardCategory, Scope, Stage, Project, Citation)
VALUES ( '#Trim(EmployeeID)#', '#Trim(Region)#', '#Trim(Division)#', '#Trim(FORM.FirstName)#', '#Trim(FORM.MiddleName)#', '#Trim(FORM.LastName)#', '#Trim(FORM.GroupAward)#','#Trim(FORM.AwardYear)#', '#Trim(FORM.Award)#','#Trim(FORM.AwardCategory)#', '#Trim(FORM.Scope)#', '#Trim(FORM.Stage)#', '#Trim(FORM.Project)#', '#Trim(FORM.Citation)#')
</cfquery>


Then I tried to model my code on somebody else's:

<cfloop from=1 to='#listlen(FORM.EmployeeID)#' index="x">
<cfquery name="Nominee" datasource="EmployeeAwards">
INSERT INTO AnnualAwards
(EmployeeID, Region, Division, FirstName, MiddleName, LastName,
GroupAward, AwardYear, Award, AwardCategory, Scope, Stage, Project,
Citation)
VALUES ('#listgetat(Trim(EmployeeID),x)#', '#Trim(Region)#', '#Trim
(Division)#', '#Trim(FORM.FirstName)#', '#Trim(FORM.MiddleName)
#', '#Trim(FORM.LastName)#', '#Trim(FORM.GroupAward)#','#Trim
(FORM.AwardYear)#', '#Trim(FORM.Award)#','#Trim(FORM.AwardCategory)
#', '#Trim(FORM.Scope)#', '#Trim(FORM.Stage)#', '#Trim(FORM.Project)
#', '#Trim(FORM.Citation)#')
</cfquery>
</cfloop>

However, what I get is 25, i.e. 5x5 instead of 5 records. Each field
in each record gets a list of the 5 values pertaining to each record
inserted.

How can I fix this code to generate a record for each EmployeeID
where the values associated with that EmployeeID will be inserted in
the proper fields? I think I have some general understanding and
could muddle through the logic, but I would appreciated anybody's
help. Thanks!

Reply to this topic