I have a procedure with about 20 flags as input parameters and each time I call the procedure with setting one of those flags so the procedure looks something like this:
Now, whenever I want to call the procedure myproc I should pass all the parameters preceding the parameter which I want to set. As example, if I want to set the flag f4 then the only way is to call the procedure like this: call myproc(0,0,0,1); My question is, is there a way to avoid the need of passing all the unneeded parameters? I mean something like call myproc(f4=1); The reason to my question was, because my flags list is more than 20 flags, and then it is inconvenient to call the procedure. |
Yes, you can specify arguments by position or by name, just as you have suggested, see here and here. Just to add: When specifying arguments via position, and you want the default value to be used, you can use the "default" keyword for that (i.e. you do not need to repeat the actual default value), such as call myproc(default, default, default, 1); One further note: As the docs tell, named parameters are only supported when using CALL or as @Sako has reported, when using SELECT ... FROM "procedure-call". They are not supported when using SELECT "function-call". 1
> you can use the "default" keyword Well done! (that tidbit is well hidden, down inside the Help topic rather than where it should be: the Syntax section)
(03 May '20, 08:47)
Breck Carter
Ah, it is already possible, but I didnt try it. Thanks a lot!
(03 May '20, 08:50)
Baron
1
@volker barth, in contrast to what you lately written, named parameters are also supported when selecting from a procedure: In my example, I can even say: select * from myproc(f4=1) Or maybe I didn't get your last point correctly?!!
(04 May '20, 04:27)
Baron
Replies hidden
1
Ah, I checked with SELECT <function-call>, and that does fail with a syntax error as expected, but it seems to work for SELECT from <proc-call>. Thanks for the pointer, and I'll adapt my answer. :)
(04 May '20, 07:16)
Volker Barth
|