Default parameters  NULL as the default parameter

Chapter 16: Using Stored Procedures

Using default parameters in stored procedures

If you create a stored procedure that uses defaults for parameters, and a user issues the stored procedure, but misspells the parameter name, Adaptive Server executes the stored procedure using the default value and does not issue an error message. For example, if you create the following procedure:

create procedure test @x int = 1
as select @x

It returns the following:

exec test @x = 2
go
----------------
                 2

However, if you pass this stored procedure an incorrect parameter, it returns an incorrect result set, but does not issue a error message:

exec test @z = 4
go
-----------
          1
(1 row affected)
(return status = 0)




Copyright © 2005. Sybase Inc. All rights reserved. NULL as the default parameter

View this book as PDF