On Thu, Jun 18, 2015 at 12:00 PM, Sven Geggus
wrote:
> David G. Johnston wrote:
>
> > Assuming you are on 9.3+ what you want to use is LATERAL
>
> OK, how is such a query supposed to look like?
>
> assuming "select myfunc(col1,col2) from mytable" works as the inner select?
>
Syntax, descriptio
David G. Johnston wrote:
> Assuming you are on 9.3+ what you want to use is LATERAL
OK, how is such a query supposed to look like?
assuming "select myfunc(col1,col2) from mytable" works as the inner select?
Sven
--
Software patents are the software project equivalent of land mines: Each
desi
Sven Geggus wrote:
> Using your suggestion the desired two columns are generated, but I consider
> this a little bit ugly:
>
> mydb=> WITH exec_func AS ( select myfunc(col1,col2) from mytable )
> SELECT (exec_func.myfunc).* FROM exec_func;
> HINWEIS: called with parms foo,bar: text1 value1
> HIN
On Thu, Jun 18, 2015 at 10:31 AM, Sven Geggus
wrote:
> David G. Johnston wrote:
> > WITH exec_func AS ( SELECT myfunc(col1,col2) FROM mytable )
> > SELECT (exec_func.myfunc).* FROM exec_func;
> >
> > This relies on the fact that currently a CTE introduces an optimization
> > barrier.
>
> Hm, let
David G. Johnston wrote:
> WITH exec_func AS ( SELECT myfunc(col1,col2) FROM mytable )
> SELECT (exec_func.myfunc).* FROM exec_func;
>
> This relies on the fact that currently a CTE introduces an optimization
> barrier.
Hm, let me summarize. My function seems to work as expected and is only
call
On Thu, Jun 18, 2015 at 9:52 AM, Sven Geggus
wrote:
> Raymond O'Donnell wrote:
>
> >> mydb=> select myfunc('foo','bar');
> >
> > You need to do:
> >
> >select * from myfunc('foo','bar');
>
> This has been a misguided example. Reality should more likely look like
> this:
>
> select myfunc(col
Raymond O'Donnell wrote:
>> mydb=> select myfunc('foo','bar');
>
> You need to do:
>
>select * from myfunc('foo','bar');
This has been a misguided example. Reality should more likely look like this:
select myfunc(col1,col2) from mytable;
And it would of course be undesired if myfunc woul
On Thu, Jun 18, 2015 at 9:32 AM, Sven Geggus
wrote:
> David G. Johnston wrote:
>
> > Look at the "returns table (col1 type, col2 type)" form.
>
> If I got this right "returns table" is not what I want as I need to select
> from my function as a virtual table in this case.
>
Yes, I mis-read you
Pavel Stehule wrote:
> CREATE OR REPLACE FUNCTION public.fx(i integer, OUT a text, OUT b text)
> RETURNS SETOF record
> LANGUAGE plpgsql
> AS $function$
> BEGIN
> RETURN QUERY SELECT 'foo'||id, 'bar'||id FROM generate_series(1,i) g(id);
> RETURN;
> END;
> $function$
I'm afraid I will almos
David G. Johnston wrote:
> Look at the "returns table (col1 type, col2 type)" form.
If I got this right "returns table" is not what I want as I need to select
from my function as a virtual table in this case.
Regards
Sven
--
"Thinking of using NT for your critical apps?
On Thursday, June 18, 2015, Chris Travers wrote:
>
>
> Select (myfunc('foo','bar')).*;
>
>
>
This should be avoided. Use lateral instead,or a cte a/o offset 0.
My_func is evaluated twice (once per column) if called this way
>
> Or
> Select * from myfunc('foo','bar');
>
This is ok
David J.
"Raymond O'Donnell" writes:
> On 18/06/2015 13:36, Sven Geggus wrote:
>> I would like to be able to do something like this:
>>
>> select myfunc('foo','bar');
>> or
>> select myfunc(foo, bar) from foobartable;
>> or even
>> select myfunc(foo, bar), 'baz' as baz from foobartable;
> You need to do:
On Thu, Jun 18, 2015 at 7:50 AM, Chris Travers wrote:
>
> On Thu, Jun 18, 2015, 14:38 Sven Geggus wrote:
>
> Hello,
>
> I supose this is simple, but I did not find a solution in the documentation.
>
> Because you already are returning 2 columns.
>
> I would like to be able to do something like th
On 18/06/2015 13:36, Sven Geggus wrote:
> Hello,
>
> I supose this is simple, but I did not find a solution in the documentation.
>
> I would like to be able to do something like this:
>
> select myfunc('foo','bar');
> or
> select myfunc(foo, bar) from foobartable;
> or even
> select myfunc(foo,
On Thu, Jun 18, 2015, 14:38 Sven Geggus
wrote:
Hello,
I supose this is simple, but I did not find a solution in the documentation.
Because you already are returning 2 columns.
I would like to be able to do something like this:
select myfunc('foo','bar');
or
select myfunc(foo, bar) from foob
Hi
CREATE OR REPLACE FUNCTION public.fx(i integer, OUT a text, OUT b text)
RETURNS SETOF record
LANGUAGE plpgsql
AS $function$
BEGIN
RETURN QUERY SELECT 'foo'||id, 'bar'||id FROM generate_series(1,i) g(id);
RETURN;
END;
$function$
postgres=# SELECT a,b FROM fx(4);
┌──┬──┐
│ a │
On Thursday, June 18, 2015, Sven Geggus wrote:
> Hello,
>
> I supose this is simple, but I did not find a solution in the
> documentation.
>
> I would like to be able to do something like this:
>
> select myfunc('foo','bar');
> or
> select myfunc(foo, bar) from foobartable;
> or even
> select myf
Hello,
I supose this is simple, but I did not find a solution in the documentation.
I would like to be able to do something like this:
select myfunc('foo','bar');
or
select myfunc(foo, bar) from foobartable;
or even
select myfunc(foo, bar), 'baz' as baz from foobartable;
Which should return som
18 matches
Mail list logo