TroyMcClure
Technical User
Hi,
As you might guess, I'm relatively new to tsql, having only dabbled with pl/sql for Oracle in the past. Most of the programming I do uses ADO. So I'm wondering if the 'cursor' in tsql is--for most intents and purposes--the the counterpart to an ADO recordset.
For instance, let's say I have a stored procedure and all I want to do is get a single value from one field in a table. I pass the procedure the key value. Now, to simply fetch and return that value, is it mandatory that I open a cursor and fetch the row and then assign that fields value to the variable via the cursor?
I would like to do it in an easier, one-line way. I had tried the sytax:
Select CusName into @SomeVariable From tblCus Where CusID = @keyvalue
This doesn't work, but I might have the syntax wrong. Is some simple syntax like that available do do what I want? I know that something like that would of course be creating some cursor behind the scenes (in the same way dlookup() in MS Access creates a temp recordset), but from a standpoint of keeping the clutter down, am I on the right track in thinking it can be done this way?
Thanks,
james
As you might guess, I'm relatively new to tsql, having only dabbled with pl/sql for Oracle in the past. Most of the programming I do uses ADO. So I'm wondering if the 'cursor' in tsql is--for most intents and purposes--the the counterpart to an ADO recordset.
For instance, let's say I have a stored procedure and all I want to do is get a single value from one field in a table. I pass the procedure the key value. Now, to simply fetch and return that value, is it mandatory that I open a cursor and fetch the row and then assign that fields value to the variable via the cursor?
I would like to do it in an easier, one-line way. I had tried the sytax:
Select CusName into @SomeVariable From tblCus Where CusID = @keyvalue
This doesn't work, but I might have the syntax wrong. Is some simple syntax like that available do do what I want? I know that something like that would of course be creating some cursor behind the scenes (in the same way dlookup() in MS Access creates a temp recordset), but from a standpoint of keeping the clutter down, am I on the right track in thinking it can be done this way?
Thanks,
james