Subject | Re: [Firebird-Architect] Re: Procedures vs functions |
---|---|
Author | Dmitry Yemanov |
Post date | 2006-03-20T05:58:42Z |
"paulruizendaal" <pnr@...> wrote:
standard. What's the point in having both CREATE FUNCTION and CREATE
PROCEDURE if functions can behave as procedures and vice versa?
There was a similar discussion regarding executable vs selectable procedures
and the decision was that they should be clearly separated objects with
different invocation patterns, so we should have:
1) Executable procedures, invoked via EXECUTE <procedure name>
2) Selectable procedures, invoked via SELECT FROM <procedure name>
Functions add one more routine type:
3) Functions, invoked via <routine invocation> syntax of <value expression>
In order to support cursors, we could offer also:
3a) Functions, invoked via SELECT FROM TABLE (<function name>)
Dmitry
>I agree here.
> In my opinion cursors should be a "first class" datatype. It should
> be possible to store cursors in variables and to pass cursors as
> parameters between procedures and functions. And yes, cursors should
> be a valid return type from a function.
> I would aim for a unification of functions and procedures, with PSQLThis is a different thing than above. And AFAIU, it partially violates the
> procedures being generalized into (possibly void) functions.
standard. What's the point in having both CREATE FUNCTION and CREATE
PROCEDURE if functions can behave as procedures and vice versa?
There was a similar discussion regarding executable vs selectable procedures
and the decision was that they should be clearly separated objects with
different invocation patterns, so we should have:
1) Executable procedures, invoked via EXECUTE <procedure name>
2) Selectable procedures, invoked via SELECT FROM <procedure name>
Functions add one more routine type:
3) Functions, invoked via <routine invocation> syntax of <value expression>
In order to support cursors, we could offer also:
3a) Functions, invoked via SELECT FROM TABLE (<function name>)
> We couldPersonally, I don't support such an unification.
> keep the current PSQL procedure syntax with the following extensions:
> - selectable procedures with one return value can be used in
> expressions as functions
> - if a udf and a procedure have the same name, the udf is used
> - SUSPEND can take a cursor as optional argument; if it has such an
> argument it will automatically loop, returning cursor rows one by one
Dmitry