I think what I've read about cursors is "use them with caution", as
programmers used to doing record-by-record manipulations a la DBase or early
MS Access may use them when they shouldn't. This may be a good place to use
them. I imagine the only way to be sure of what will be more efficient is
to test.
By the way, you may be able to save one calculation; in some SQL
implementations you can use a number in the order by clause that identifies
which item in the SELECT clause you wish to sort by, e.g.
select myfield, yourfield
from sometable
order by 1
which orders by "myfield".
-----Original Message-----
From: Dick Applebaum [mailto:[EMAIL PROTECTED]]
Sent: Monday, September 25, 2000 6: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
----------------------------------------------------------------------------
--
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.
------------------------------------------------------------------------------
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.