Re: Calling functions from within pl/pgsql

Lists: pgsql-sql
From: Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Calling functions from within pl/pgsql
Date: 2007-12-04 12:16:50
Message-ID: 200712041416.50322.achill@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

I noticed that in pl/pgsql simply
result := funcname(func,args,...);
just works.
Should i rely on it or take it as a coincidence? :)
--
Achilleas Mantzios


From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Achilleas Mantzios" <achill(at)matrix(dot)gatewaynet(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Calling functions from within pl/pgsql
Date: 2007-12-04 12:59:43
Message-ID: 162867790712040459s6ee86399h5dac46cc20d95e9f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

On 04/12/2007, Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com> wrote:
> I noticed that in pl/pgsql simply
> result := funcname(func,args,...);
> just works.
> Should i rely on it or take it as a coincidence? :)

You found assignment :). Sure, you can use it.
http://www.postgresql.org/docs/8.2/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-ASSIGNMENT

Regards
Pavel Stehule

> --
> Achilleas Mantzios
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>


From: Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Calling functions from within pl/pgsql
Date: 2007-12-04 13:23:04
Message-ID: 200712041523.05011.achill@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Στις Tuesday 04 December 2007 14:59:43 ο/η Pavel Stehule έγραψε:
> On 04/12/2007, Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com> wrote:
> > I noticed that in pl/pgsql simply
> > result := funcname(func,args,...);
> > just works.
> > Should i rely on it or take it as a coincidence? :)
>
> You found assignment :). Sure, you can use it.
> http://www.postgresql.org/docs/8.2/interactive/plpgsql-statements.html#PLPG
>SQL-STATEMENTS-ASSIGNMENT

Sure, i missed the
"As explained above, the expression in such a statement is evaluated by means
of an SQL SELECT command sent to the main database engine. The expression
must yield a single value."
part.
Thanx.

>
> Regards
> Pavel Stehule
>
> > --
> > Achilleas Mantzios
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 6: explain analyze is your friend

--
Achilleas Mantzios


From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Achilleas Mantzios" <achill(at)matrix(dot)gatewaynet(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Calling functions from within pl/pgsql
Date: 2007-12-04 13:41:51
Message-ID: 162867790712040541j296bbc8dt9383293690872c64@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Hello

a := exprx

is internally translated :
get result of SELECT exprx
and store it to a

so you can write select sin(10); then you can a := sin(10)

but you can too use subselect like:

SELECT (SELECT v FROM foo LIMIT 1) ~ you can write

a := (SELECT v FROM foo LIMIT 1);

that is equal to SELECT INTO a v FROM foo

Pavel

> > http://www.postgresql.org/docs/8.2/interactive/plpgsql-statements.html#PLPG
> >SQL-STATEMENTS-ASSIGNMENT
>
> Sure, i missed the
> "As explained above, the expression in such a statement is evaluated by means
> of an SQL SELECT command sent to the main database engine. The expression
> must yield a single value."
> part.
> Thanx.
>
> >
> > Regards
> > Pavel Stehule
> >
> > > --
> > > Achilleas Mantzios
> > >
> > > ---------------------------(end of broadcast)---------------------------
> > > TIP 6: explain analyze is your friend
>
>
>
> --
> Achilleas Mantzios
>