Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

3 cfquery Updates

Guest
Sep 04, 2008 Sep 04, 2008
I have a template that updates 3 database tables with three different cfquery update statements. For some reason the second 2 are not updating the data specified by the query. Here is a look at the code.

<CFQUERY NAME = "SubJob" datasource="#REQUEST.DataSource#">
UPDATE SubJob
SET SubJobNumber = '#FORM.SubJobNumber#',
Project = '#FORM.Project#',
PONumber = '#FORM.PONumber#',
OriginalPOAMT = '#FORM.OriginalPOAMT#',
WONumber = '#FORM.WONumber#',
AccountNumber = '#FORM.AccountNumber#',
PreparedBy = '#FORM.PreparedBy#',
ProjectEngineer = '#FORM.ProjectEngineer#'
WHERE SubJobNumber = 'N' AND
JobNumber = '#URL.JobNumber#'
</cfquery>

<CFQUERY DATASOURCE="#REQUEST.DataSource#" name="SubJob1">
UPDATE Productivity
SET SubJobNumber = '#FORM.SubJobNumber#'
WHERE SubJobNumber = 'N' AND
JobNumber = '#URL.JobNumber#'
</CFQUERY>


<CFQUERY DATASOURCE="#REQUEST.DataSource#" name="SubJob2">
UPDATE CostJobApproval
SET SubJobNumber = '#FORM.SubJobNumber#'
WHERE SubJobNumber = 'N' AND
JobNumber = '#URL.JobNumber#'
</CFQUERY>
TOPICS
Database access
473
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 07, 2008 Sep 07, 2008
For some reason the second 2 are not updating the data specified by the query.
There is no apparent reason for them to fail. How do you know the first works and the last two don't? Add the following code at the end and verify the result in the dumps:

<CFQUERY DATASOURCE="#REQUEST.DataSource#" name="SubJob3">
SELECT SubJobNumber
FROM Productivity
WHERE SubJobNumber = '#FORM.SubJobNumber#'
AND JobNumber = '#URL.JobNumber#'
</CFQUERY>

<CFQUERY DATASOURCE="#REQUEST.DataSource#" name="SubJob4">
SELECT SubJobNumber
FROM CostJobApproval
WHERE SubJobNumber = '#FORM.SubJobNumber#' AND
JobNumber = '#URL.JobNumber#'
</CFQUERY>

<cfdump var="#SubJob3#">
<cfdump var="#SubJob4#">


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 07, 2008 Sep 07, 2008
Forget it. Just noticed that you posted all over the place. Please, don't do it. You wont get three times as many reactions that way.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 07, 2008 Sep 07, 2008
LATEST
> UPDATE Productivity
> SET SubJobNumber = '#FORM.SubJobNumber#'
> WHERE SubJobNumber = 'N' AND
> JobNumber = '#URL.JobNumber#'

I presume it's because that filter doesn't match any reocrds in that table.

You might want to do a Google search on "SQL injection attacks" as
motivation for getting <cfqueryparam> tags on all your dynamic values,
ASAP.

--
Adam
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources