Search code examples
parameterssybase-asa

Sybase ASA 9 Stored procedure, use default parameter


I have a stored procedure'test' in Sybase ASA with for example 4 parameters.

par1 INT = 0,
par2 VARCHAR(50) = NULL,
par3 VARCHAR(100) = NULL,
par4 VARCHAR(10) = ''

Now I want to execute this stored procedure with par1 as its default value.

call test(NULL, 'test')

But the actual value of par1 i not 0, but 1!

I also tried

call test(DEFAULT, 'test')

but that doesn't run.


Solution

  • 1) The first example did not work because you passed in a NULL value.

    2) I'm not quite sure of which syntax you are using for his SP (never heard of "par1"), but using standard syntax, what you need to do is to have named parameters in SP and in the call:

    CREATE PROCEDURE test( INOUT var1 INT DEFAULT 0,

                       INOUT var2 VARCHAR(50)  DEFAULT NULL,
    
                       INOUT var3 VARCHAR(100) DEFAULT NULL,
    
                       INOUT var3 VARCHAR(10)  DEFAULT '')
    

    and then call

    CALL test (var2 = 'test')