Dick
I would use a stored proc.
You might be able to use variables inside the stored proc to avoid
recalculating, but even if you can't, the DBMS might optimize
it automatically, and even if it doesn't, this is only CPU stuff.
Nick
-----Original Message-----
From: Dick Applebaum [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 25, 2000 11:50 PM
To: CF-Talk
Subject: [OT} Advice on SQL Cursor
I have a query that involves a distance calculation. This actually
is series of trig functions computed for each row in the recordset.
some of the sub calculations are repeated several times (degrees to
radians),
test to avoid divide by zero, etc.
the overall calculation is repeated at least twice once in the SELECT
clause
and again in the WHERE clause
and possibly in the ORDER BY clause
This seems inefficient and I am looking for a better way.
The inefficiency is caused by the inability to compute a value and
set a variable for each record... and then reuse the variable later
in the processing of the same record (rather than recompute the value
for each occurrence of the calculation).
The only way I can see to do this is by using a cursor...
Everything I have been told or read about cursors says to avoid them.
However, a cursor seems better than:
an inefficient query or sproc (above)
returning the entire recordset to CF and then loop through the query,
performing the calculations
Any recommendations?
TIA
Dick
**********************************************************************
Information in this email is confidential and may be privileged.
It is intended for the addressee only. If you have received it in error,
please notify the sender immediately and delete it from your system.
You should not otherwise copy it, retransmit it or use or disclose its
contents to anyone.
Thank you for your co-operation.
**********************************************************************
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.