
> Thomas Lockhart <lockhart@alumni.caltech.edu> writes:
> >   create table t1 (x int);
> >   create function foo (out int) returns int as ...;
> >   select foo(x) from t1;
> 
> > will give two columns for the result.
> 
> You've *got* to be kidding.
> 
> To name just one problem with that, where do I put an AS to relabel
> the extra column?

It gets the name of the variable ( here "out"), no way to rename it,
but no problem since you can name the variable however you like.

Andreas 

Tue, 27 Jun 2000 16:53:30 +0200
Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at>
AW: SQL99 functions 
> > >   create function foo (out int) returns int as ...;
> > >   select foo(x) from t1;
> > > will give two columns for the result.
> > You've *got* to be kidding.
> > To name just one problem with that, where do I put an AS to relabel
> > the extra column?
> It gets the name of the variable ( here "out"), no way to rename it,
> but no problem since you can name the variable however you like.

Actually, there is a third (optional) field which is the variable name:

  create function foo (out pname int) returns int as ...;

Not sure what it should default to if the name is not specified.

                  - Thomas

Tue, 27 Jun 2000 15:07:31 +0000
Thomas Lockhart <lockhart@alumni.caltech.edu>
Re: AW: SQL99 functions
Zeugswetter Andreas SB <ZeugswetterA@wien.spardat.at> writes:
>> Thomas Lockhart <lockhart@alumni.caltech.edu> writes:
>>>> create table t1 (x int);
>>>> create function foo (out int) returns int as ...;
>>>> select foo(x) from t1;
>> 
>>>> will give two columns for the result.
>> 
>> You've *got* to be kidding.
>> 
>> To name just one problem with that, where do I put an AS to relabel
>> the extra column?

> It gets the name of the variable ( here "out"), no way to rename it,
> but no problem since you can name the variable however you like.

What?  OUT is a keyword there; I don't see any explicit name for the
function's formal parameter at all.


BTW, what happens when I use foo() in a place other than the top level
of a SELECT list?

Examples:

	SELECT (CASE WHEN x > 0 THEN foo(x) ELSE 42 END) FROM table

	SELECT x FROM table WHERE foo(x) > 0


Also, I still haven't figured out what INOUT is supposed to do.


There are some things that are too brain-dead to consider implementing,
whether they are in SQL99 or not, and this is sounding a lot like
one of them...

			regards, tom lane

Tue, 27 Jun 2000 11:15:01 -0400
Tom Lane <tgl@sss.pgh.pa.us>
Re: AW: SQL99 functions 