Skip to main content
Completed

Optional parameters in procedures

Related products:Software FactoryIndicium Service Tier

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

 

Did this topic help you find an answer to your question?

Jasper
Superhero
  • January 14, 2021
Updated idea status NewOpen

Forum|alt.badge.img

This should also apply to `functions` 


Mark Jongeling
Administrator
Forum|alt.badge.img+23
OpenOn the backlog

Forum|alt.badge.img

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


Mark Jongeling
Administrator
Forum|alt.badge.img+23

@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.


Mark Jongeling
Administrator
Forum|alt.badge.img+23
On the backlogWorking on it!

Mark Jongeling
Administrator
Forum|alt.badge.img+23

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.


Mark Jongeling
Administrator
Forum|alt.badge.img+23
Working on it!Next release

Jeroen van den Belt
Administrator
Forum|alt.badge.img+8
Next releaseCompleted

Jeroen van den Belt
Administrator
Forum|alt.badge.img+8
The following idea has been merged into this idea:

All the votes have been transferred into this idea.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings