Skip to main content

As far as i can see, there is no option in the SF to define default values for subroutine parameters. When a default value could be defined they become an optional parameter in SQL server. 

I would like to suggest this add such an option in the SF?
The advantage is that you don’t have to define all parameters when calling a subroutine.

As far as I can see is that in the subroutine parameters an extra field should be added with default value. In the generate process the declaration of the parameters need to be changed so the variable will be declared as:
create procedure proc_1 
( @a id

 @b id = 0

as begin

 In this case @b becomes an optional parameter and when calling procedure proc_1 there is no need to pass a value for parameter @b

 

Updated idea status NewOpen

This should also apply to `functions` 


OpenOn the backlog

This will be helpful for us too.


We have a procedure that will be extended with more parameters overtime.
But the issue that will arise with new parameters is that we need to add the extra parameter on all places in code where the procedure is called


@kenterweeme, Procedures will be possible to extend this way once this idea is implemented. Functions do always require all parameters to be filled, either with a value or with keyword DEFAULT.


On the backlogWorking on it!

From 2025.1, you will be able to specify default values for your Functions and Procedures (Subroutines) in your SQL Server, Oracle, and DB2 models. Note that the default values can only be literals, numbers, or NULL. Expressions or queries are not supported by any RDBMS.

Subroutine parameter with Default value

The Program object will add the default value to the parameter definition for you:

Program object generated code

To execute this procedure in your code, you can now do the following:

-- Default value will be used
execute generate_objects

-- Use a different value for the named parameter
execute generate_objects @generate_all_objects = 0
-- Or index-based
execute generate_objects 0

For more information, follow the documentation of your RDBMS.


Working on it!Next release