![]() | ![]() |
Home |
|
|
Transact-SQL User's Guide |
|
| Chapter 14 Using Stored Procedures |
|
| Creating and executing stored procedures |
|
| Setting options in stored procedures |
You can use some of the set command options inside a stored procedure. The set option remains in effect during the execution of the procedure and most options revert to the former setting at the close of the procedure. Only the dateformat, datefirst, and language options do not revert to their former settings.
However, if you use a set option (such as identity_insert) that requires the user to be the object owner, a user who is not the object owner cannot execute the stored procedure.
Arguments for stored proceduresThe maximum number of arguments for stored procedures is 2048. However, you may notice a performance degradation if you execute procedures with large numbers of arguments, because the query processing engine must process all the arguments and copy argument values to and from memory. Sybase recommends that you first test any stored procedures you write that include large numbers of arguments before you implement them in a production environment.
Length of expressions, variables, and SP argumentsThe maximum size for expressions, variables, and arguments passed to stored procedures is 16384 (16K) bytes, for any page size. This can be either character or binary data. You can insert variables and literals up to this maximum size into text columns without using the writetext command.
When you upgraded Adaptive Server and the prior version used a lower maximum length:
Earlier versions of Adaptive Server had a maximum size of 255 bytes for expressions, variables, and arguments for stored procedures.
Any scripts or stored procedures that you wrote for earlier versions of Adaptive Server that used this old maximum may now return larger string values because of the larger maximum page sizes.
Because of the larger value, Adaptive Server may truncate the string, or the string may cause overflow if it was stored in another variable or inserted into a column or string.
If columns of existing tables are modified to increase the length of character columns, you must change any stored procedures that operate data on these columns to reflect this new length.
select datalength(replicate("x", 500)), datalength("abcdefgh....255 byte long string.." + "xxyyzz ... another 255 byte long string")----------- -----------255 255
|
|