People,
I've inherited a lot of SP embedded SQL code that makes substantial
use of FOR cursors rather than DECLARED, and I am wondering whether
there is a significant difference in the performance of either.
With the declared cursor, perhaps opening, and using a 'while' loop to
fetch each record, what would be the main differences in the author
using a FOR statement in lieu thereof ? The results of the FOR
statement are seemingly to perform a significant number of inserts or
updates after modifying several variables.
I know the insert /update performance will depend on many other
underlying factors, but for management of the overall record set,
which would be the preferred manner ? I could see it being done either
way to be honest.
As an aside, the author obviously never chose to use any dynamic SQL
or to use parameter variable inserts [ ? ] as they are all presently
'values' and variables either determined by function call or set from
select statements.
My recent readings lead me to believe this code is somewhat [very]
inefficient in its present state and could do with a serious overhaul.
Any insight or guidance for overall efficiency would be appreciated.
Many thanks,
Tim