<CFIF ListLen(SESSION.WHSurveyStruct.reasonString, ";") gt 0> <CFQUERY name="insertReasons" datasource="#REQUEST.dsn#"> INSERT INTO TWelcomeHome_Reason (ReasonID, SubReasonID, SurveyID) SELECT #sanitize(ListFirst(SESSION.WHSurveyStruct.reasonString, ";"))#, #sanitize(getLatestSurveyID.SurveyID)# <CFLOOP list="#sanitize(ListRest(SESSION.WHSurveyStruct.reasonString, ';'))#" index="thisReason" delimiters=";"> UNION ALL SELECT #sanitize(thisReason)#, #sanitize(getLatestSurveyID.SurveyID)# </CFLOOP> </CFQUERY>
I'm trying to figure out what this does. I am confused with a loop, why not have a FROM expression? Well, they are just scalars.
How about choosing an operator outside the loop and one inside? I donβt seem to understand the meaning of union all . And how did it happen that three columns are indicated (ReasonID, SubReasonID, SurveyID), but in each value of select 2?
dropped:
structure
CACHED: false EXECUTIONTIME: 0 RECORDCOUNT: 8 SQL: INSERT INTO TWelcomeHome_Reason (ReasonID, SubReasonID, SurveyID) SELECT 6, 18, 245 UNION ALL
SELECT 6, 21, 245
UNION ALL
SELECT 6, 24, 245
UNION ALL
SELECT 3, 5, 245
UNION ALL
CHOOSE 3, 6, 245
UNION ALL
SELECT 3, 8, 245
UNION ALL
SELECT 3, 11, 245
UNION ALL
SELECT 3, 7, 245