set rowcount inside SP 
Author Message
 set rowcount inside SP

I am a novice SQL programmer, with the task of speeding up a rather complex
stored procedure.  I have determined that I can get a big win by using the
Sybase specific "set rowcount 1" before a select statement (and then turn it
off with "set rowcount 0").  Am I correct in assuming that this will only
affect this one query?  It is not a global flag for the server?  I looked
in the referance manual and the FAQ, but could not be sure.  Obviously, I
cannot afford to affect results of other queries running on the server.

--
/*
 *   David Mearns

 */
#include <disclaimer.h>



Sun, 27 Feb 2000 03:00:00 GMT
 set rowcount inside SP

Quote:

> I am a novice SQL programmer, with the task of speeding up a rather complex
> stored procedure.  I have determined that I can get a big win by using the
> Sybase specific "set rowcount 1" before a select statement (and then turn it
> off with "set rowcount 0").  Am I correct in assuming that this will only
> affect this one query?  It is not a global flag for the server?  I looked
> in the referance manual and the FAQ, but could not be sure.  Obviously, I
> cannot afford to affect results of other queries running on the server.

        You are correct. User settable options are for the most part
        applicable only to the connection setting them. There are
        exceptions, of course. Look up the set command in your Sybase
        reference manual. For further points you can wonder why there
        is no equivalent get command.

-am



Sun, 27 Feb 2000 03:00:00 GMT
 set rowcount inside SP

Hello,

        Yes, you are correct. Set rowcount to the number of rows you want
immediately prior to the select statement and them set rowcount=0
immediately after the select statment. This will, in effect, turn
rowcount off.

Robert

Quote:

> I am a novice SQL programmer, with the task of speeding up a rather complex
> stored procedure.  I have determined that I can get a big win by using the
> Sybase specific "set rowcount 1" before a select statement (and then turn it
> off with "set rowcount 0").  Am I correct in assuming that this will only
> affect this one query?  It is not a global flag for the server?  I looked
> in the referance manual and the FAQ, but could not be sure.  Obviously, I
> cannot afford to affect results of other queries running on the server.

> --
> /*
>  *   David Mearns

>  */
> #include <disclaimer.h>



Sun, 27 Feb 2000 03:00:00 GMT
 set rowcount inside SP

|>
|> I am a novice SQL programmer, with the task of speeding up a rather complex
|> stored procedure.  I have determined that I can get a big win by using the
|> Sybase specific "set rowcount 1" before a select statement (and then turn it
|> off with "set rowcount 0").  Am I correct in assuming that this will only
|> affect this one query?  It is not a global flag for the server?  I looked
|> in the referance manual and the FAQ, but could not be sure.  Obviously, I
|> cannot afford to affect results of other queries running on the server.

Correct, set rowcount is session-specific.

--
---------------------------------------------------------------------
| Bret Halford                    Imagine my disappointment       __|
| Sybase Technical Support        in learning the true nature  __|  
| 6400 S. Fiddlers Green Circle   of rec.humor.oracle...    __|  
| Englewood, CO 80111-4954 USA                             |
============================================================



Sun, 27 Feb 2000 03:00:00 GMT
 set rowcount inside SP

David,

You're correct -- it will affect only the one query.  Just be aware that
unless you  write a where clause that gets you the exact row you want,
you won't have any control over *which* one row you get back.

Billie Patterson

--
Remove the antispam "_AT_" from my e-mail address to reply directly.

Quote:

> I am a novice SQL programmer, with the task of speeding up a rather complex
> stored procedure.  I have determined that I can get a big win by using the
> Sybase specific "set rowcount 1" before a select statement (and then turn it
> off with "set rowcount 0").  Am I correct in assuming that this will only
> affect this one query?  It is not a global flag for the server?  I looked
> in the referance manual and the FAQ, but could not be sure.  Obviously, I
> cannot afford to affect results of other queries running on the server.

> --
> /*
>  *   David Mearns

>  */
> #include <disclaimer.h>



Fri, 03 Mar 2000 03:00:00 GMT
 
 [ 5 post ] 

 Relevant Pages 

1. Set @@rowcount to a local var in one SP from another SP

2. SET ROWCOUNT inside of a user-defined function

3. How can I call a SP inside a SP without the owner name

4. Using a SP inside another SP

5. Calling SP from inside another SP

6. Use a sp to Make a view with a sp inside

7. sp inside sp

8. calling SP inside SP

9. How Get Output Param from Inside SP, calling another SP

10. Check if parameter supplied to SP inside SP

11. SET ROWCOUNT set by ODBC...

12. rowcount inside view


 
Powered by phpBB® Forum Software