Thursday, March 29, 2012

CURSOR QUESTION ??...

Can I use paremeters in Cursor within the SP as:
DECLARE c_Stbls CURSOR FOR
SELECT @.columnparemeter FROM @.tableparemeter
where both @.columnparemeter and @.tableparemeter are input paremeters from
the SP.
How do I acomplish this within a SP ?
Thanks,
TomdOn Tue, 4 Oct 2005 15:37:07 -0700, tom d wrote:

>Can I use paremeters in Cursor within the SP as:
>DECLARE c_Stbls CURSOR FOR
>SELECT @.columnparemeter FROM @.tableparemeter
>where both @.columnparemeter and @.tableparemeter are input paremeters from
>the SP.
>How do I acomplish this within a SP ?
Hi Tom,
Typically, you don't.
Both cursors and dynamic SQL are last resort solution, that you should
only consider when everything elsse fails. Here, you are basically
trying to use them both.
Could you explain what you're trying to achieve? I.e.: *why* do you have
to open a cursor for an unknown column in an unknown table?
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||Why a cursor? Worse, why a *dynamic* cursor? These are the twin evils of
last resort so I'm convinced there ought to be a better way. If you're not
convinced then see the following article for some examples that might help
and some advice that might change your mind.
http://www.sommarskog.se/dynamic_sql.html
David Portas
SQL Server MVP
--
"tom d" <tomd@.discussions.microsoft.com> wrote in message
news:E8B003BC-D407-4D38-BA1A-A815506BC0E9@.microsoft.com...
> Can I use paremeters in Cursor within the SP as:
> DECLARE c_Stbls CURSOR FOR
> SELECT @.columnparemeter FROM @.tableparemeter
> where both @.columnparemeter and @.tableparemeter are input paremeters from
> the SP.
> How do I acomplish this within a SP ?
> Thanks,
> Tomd|||"Twin evils of last resort" Use them only if the relational potion your
quaff turns out to be water, and your sceptre has been drained of all set
based powers :)
And I agree with both David and Hugo, give us an idea of what you are trying
to do and we can help out a bit more.
--
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
news:T5Wdnbn8v-eemt7enZ2dnUVZ8qmdnZ2d@.giganews.com...
> Why a cursor? Worse, why a *dynamic* cursor? These are the twin evils of
> last resort so I'm convinced there ought to be a better way. If you're not
> convinced then see the following article for some examples that might help
> and some advice that might change your mind.
> http://www.sommarskog.se/dynamic_sql.html
> --
> David Portas
> SQL Server MVP
> --
> "tom d" <tomd@.discussions.microsoft.com> wrote in message
> news:E8B003BC-D407-4D38-BA1A-A815506BC0E9@.microsoft.com...
>|||Another Reason for why you should not use?
Belive Me, You will end up with lots of frustration when you want to use
dynamic cursors.
--
Regards
R.D
--Knowledge gets doubled when shared
"Louis Davidson" wrote:

> "Twin evils of last resort" Use them only if the relational potion your
> quaff turns out to be water, and your sceptre has been drained of all set
> based powers :)
> And I agree with both David and Hugo, give us an idea of what you are tryi
ng
> to do and we can help out a bit more.
> --
> ----
--
> Louis Davidson - http://spaces.msn.com/members/drsql/
> SQL Server MVP
> "Arguments are to be avoided: they are always vulgar and often convincing.
"
> (Oscar Wilde)
> "David Portas" <REMOVE_BEFORE_REPLYING_dportas@.acm.org> wrote in message
> news:T5Wdnbn8v-eemt7enZ2dnUVZ8qmdnZ2d@.giganews.com...
>
>

No comments:

Post a Comment