Re: Looking info for SCSYNTHETIC CURSOR



On Feb 16, 2:53 am, "adisa...@xxxxxxxxx" <adisa...@xxxxxxxxx> wrote:
Hi everybody,

looking for more info refering SCSYBTHETIC CURSOR to use ti in my
store
procedure.

I checked in T-SQL Guide on sybase 12.5.x but I did not fin any
information

Thanks in advance

Regards
Antonio

My only exposure to the term "synthetic cursor" is within a Sybase
ASE context where code like the following is used in lieu of the more
standard cursor declare, fetch, read, etc. Somewhat surprisingly
(for me at least), the synthetic cursor seems to always performs
better than the real deal, in my experience; requires less code, and
uses simpler, more SQL common syntax to achieve
the same end -- if you can use it. You must be able to derive a
single-element, sortable primary key for this to work, and you must be
able to process the rows in that sort order

declare @myKey numeric

select @myKey = min(myKey) from myTable where myKey > isnull(@myKey,
0) /* and.... */
while @myKey is not null
begin -- {

/* Perform record-oriented login on the row referenced by @myKey
*/

/* Get the next row */
select @myKey = min(myKey) from myTable where myKey >
isnull(@myKey,0) /* and.... */

end -- }

'hope that helps,

Keith

.