2023-09-19 12:14:02 +02:00
|
|
|
# Named arguments for function and procedure calling (FB 6.0)
|
|
|
|
|
2023-05-03 02:58:44 +02:00
|
|
|
Named arguments allows you to specify function and procedure arguments by their names, rather than only
|
|
|
|
by their positions.
|
2023-09-19 12:14:02 +02:00
|
|
|
|
2023-05-03 02:58:44 +02:00
|
|
|
It is especially useful when the routine have a lot of parameters and you want to specify them in arbitrary
|
|
|
|
order or not specify some of those who have default values.
|
2023-09-19 12:14:02 +02:00
|
|
|
|
|
|
|
As the positional syntax, all arguments without default values are required to be present in the call.
|
|
|
|
|
2023-05-03 02:58:44 +02:00
|
|
|
A call can use positional, named or mixed arguments. In mixed syntax, positional arguments must appear before
|
|
|
|
named arguments.
|
2023-09-19 12:14:02 +02:00
|
|
|
|
|
|
|
## Syntax
|
|
|
|
|
|
|
|
```
|
|
|
|
<function call> ::=
|
|
|
|
[<package name> .] <function_name>( [<arguments>] )
|
|
|
|
|
|
|
|
<procedure selection> ::=
|
|
|
|
[<package name> .] <procedure_name> [( <arguments> )]
|
|
|
|
|
|
|
|
<execute procedure> ::=
|
|
|
|
EXECUTE PROCEDURE [<package name> .] <procedure name>
|
|
|
|
[{ (<arguments>) | <arguments> }]
|
|
|
|
[RETURNING_VALUES ...]
|
|
|
|
|
|
|
|
<arguments> ::=
|
2023-05-03 02:58:44 +02:00
|
|
|
<positional arguments> |
|
|
|
|
[ {<positional arguments>,} ] <named arguments>
|
|
|
|
|
|
|
|
<positional arguments> ::=
|
2023-09-19 12:19:19 +02:00
|
|
|
<value or default> [ {, <value or default>}... ]
|
2023-09-19 12:14:02 +02:00
|
|
|
|
|
|
|
<named arguments> ::=
|
|
|
|
<named argument> [ {, <named argument>}... ]
|
|
|
|
|
|
|
|
<named argument> ::=
|
2023-09-19 12:19:19 +02:00
|
|
|
<argument name> => <value or default>
|
|
|
|
|
|
|
|
|
|
|
|
<value or default> ::=
|
|
|
|
<value> |
|
|
|
|
DEFAULT
|
2023-09-19 12:14:02 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
```
|
|
|
|
select function_name(parameter2 => 'Two', parameter1 => 1)
|
|
|
|
from rdb$database
|
|
|
|
```
|
|
|
|
|
2023-05-03 02:58:44 +02:00
|
|
|
```
|
|
|
|
select function_name(1, parameter2 => 'Two')
|
|
|
|
from rdb$database
|
|
|
|
```
|
|
|
|
|
2023-09-19 12:19:19 +02:00
|
|
|
```
|
|
|
|
select function_name(default, parameter2 => 'Two')
|
|
|
|
from rdb$database
|
|
|
|
```
|
|
|
|
|
2023-09-19 12:14:02 +02:00
|
|
|
```
|
|
|
|
execute procedure insert_customer(
|
|
|
|
last_name => 'SCHUMACHER',
|
|
|
|
first_name => 'MICHAEL')
|
|
|
|
```
|
|
|
|
|
|
|
|
```
|
|
|
|
select *
|
|
|
|
from get_customers(city_id => 10, last_name => 'SCHUMACHER')
|
|
|
|
```
|