CODE
<cffunction name="processDoc">
<cfargument name="insertDocFields" type="string">
<cfargument name="insertDocValues" type="string">
<cfquery name="insertDoc" datasource="CAC">
INSERT INTO GuidanceDocument(#insertDocFields#)
VALUES (#insertDocValues#)
</cfquery>
</cffunction>
<cfoutput>
#processDoc('Title, Description_E, Description_F,
Document_Language, Country_UID, Location, PRTR_Site,
PRTR_Rep, PRTR_Rep_email, DTimeEntered, Source_org,
UserLastModified',
"'form.docTitle', 'form.descE', 'form.descF', 'form.language',
'country', 'form.docLink', 'form.prtrCO', 'form.prtrRep',
'form.prtrEmail', now(), 'form.docOrg', 'Session.UserName'")#
</cfoutput>
<cfargument name="insertDocFields" type="string">
<cfargument name="insertDocValues" type="string">
<cfquery name="insertDoc" datasource="CAC">
INSERT INTO GuidanceDocument(#insertDocFields#)
VALUES (#insertDocValues#)
</cfquery>
</cffunction>
<cfoutput>
#processDoc('Title, Description_E, Description_F,
Document_Language, Country_UID, Location, PRTR_Site,
PRTR_Rep, PRTR_Rep_email, DTimeEntered, Source_org,
UserLastModified',
"'form.docTitle', 'form.descE', 'form.descF', 'form.language',
'country', 'form.docLink', 'form.prtrCO', 'form.prtrRep',
'form.prtrEmail', now(), 'form.docOrg', 'Session.UserName'")#
</cfoutput>
Output with query:
QUOTE
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'form'.
INSERT INTO GuidanceDocument(Title, Description_E, Description_F, Document_Language, Country_UID, Location, PRTR_Site, PRTR_Rep, PRTR_Rep_email, DTimeEntered, Source_org, UserLastModified) VALUES (''form.docTitle'', ''form.descE'', ''form.descF'', ''form.language'', ''country'', ''form.docLink'', ''form.prtrCO'', ''form.prtrRep'', ''form.prtrEmail'', now(), ''form.docOrg'', ''Session.UserName'')
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'form'.
INSERT INTO GuidanceDocument(Title, Description_E, Description_F, Document_Language, Country_UID, Location, PRTR_Site, PRTR_Rep, PRTR_Rep_email, DTimeEntered, Source_org, UserLastModified) VALUES (''form.docTitle'', ''form.descE'', ''form.descF'', ''form.language'', ''country'', ''form.docLink'', ''form.prtrCO'', ''form.prtrRep'', ''form.prtrEmail'', now(), ''form.docOrg'', ''Session.UserName'')
Output without query:
QUOTE
Fields: Title, Description_E, Description_F, Document_Language, Country_UID, Location, PRTR_Site, PRTR_Rep, PRTR_Rep_email, DTimeEntered, Source_org, UserLastModified
Values: 'form.docTitle', 'form.descE', 'form.descF', 'form.language', 'country', 'form.docLink', 'form.prtrCO', 'form.prtrRep', 'form.prtrEmail', now(), 'form.docOrg', 'Session.UserName'
Values: 'form.docTitle', 'form.descE', 'form.descF', 'form.language', 'country', 'form.docLink', 'form.prtrCO', 'form.prtrRep', 'form.prtrEmail', now(), 'form.docOrg', 'Session.UserName'
EDIT: I discovered that I forgot to add # before and after each value. I still get the same double single quote problem. I also tried <cfset insertDocValues = Replace(insertDocValues,"''","'","ALL")> before my query and it still doesn't work. I guess the query adds the extra '.
Someone told me to use arrays instead since coldfusion will automatically escape all ' from a string. I have 2 loops going from 1 to 12 and every time I refresh it seems to take ages to reload. Any idea?
Issue pretty much resolved.
