Skip to main content
Known Participant
August 27, 2012
Question

Two web pages with identical queries, different results.

  • August 27, 2012
  • 10 replies
  • 1235 views

How can two pages give different results from the same exact query?

I have pages that are part of my application.  Immediately after an Update query, the results of the update are not displayed on the applicable page of my application via a Select query. 

When I subsequently execute the identical Select query in a page that is not part of my application (or in SQL Server MMC), it shows the results of the update correctly every time.

I have turned off query caching (When I do a CFDUMP of the query, it always shows Cached=false) and do not keep any browser history in Firefox.  I also set the Expires header value in all my pages, and added a dummy clause to end of my Where clause so that the query is always different.

The other issue is that it seems to be happening randomly.

What could be causing this?  It is driving me crazy.

Richard

This topic is closed to new replies. Start a new post to keep the conversation going.

10 replies

Miguel-F
Inspiring
August 28, 2012

Can you share your queries and the results?

Known Participant
August 28, 2012

I would like to first present a disclaimer that I inherited this database and have nothing to do with its current design...

I have a page that is displaying a list of 10 steps with the following query:

SELECT rx.* ,co.cont_firstname,co.cont_lastname

FROM ProcessRxIntake RX

INNER JOIN Contacts CO

ON RX.Contacts_ID = CO.Contacts_ID

WHERE RX.Contacts_ID = #URL.ID#

The output from this page displays a list of 10 steps (with links to the page for that step) with its status as either Validated or Not Validated.  The validation status is stored in the table ProcessRxIntake in the fields Valid1, Valid2, Valid3, ..., Valid10.

Each step page contains three buttons added via a cfinclude page: Mark as Not Valid, Mark as Valid, and Cancel.  The first two these buttons results in a form submission whose action page executes the following query:

UPDATE ProcessRXIntake SET #updatefield# = #valid# WHERE contacts_id = #form.id#

Where updatefield is valid1 or valid2, etc. and valid is 0 or 1, which are set from values received from the form.

After executing the query, it redirects back to the step page.

Occasionally, the step page will not display the updated value of the validation, while in SQL Server MMC or a test page that executes the same above query displays the values correctly.

I added this to the WHERE clause in the above query to force it to always be a different query:

or (1 = #second(now())#)

but it still occasionally doesn't work.

I have cachedwithin="#CreateTimeSpan(0, 0, 0, 1)#" as a cfquery attribute.  I have also tried setting the maximum number of cached queries in the coldfusion administrator to 0.  It still intermittently doesn't work.

That is the worst part...it is intermittent!

When I cfdump the above query, it always shows cached=false.

I have also tried qualifying my tables with (NOLOCK), but that still hasn't had an affect.

Inspiring
August 28, 2012

It could be that all the processing is taking place in less than a second, in which case your original select query is still cached.  Since your intent is to not cache the query, the cachedwithin attribute is not doing anything useful for you anyway.  I suggest getting rid of it.