Re: Strange syntax with select - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Strange syntax with select
Date
Msg-id 567D8184.7060502@aklaver.com
Whole thread Raw
In response to Re: Strange syntax with select  ("Edson F. Lidorio" <edson@openmailbox.org>)
Responses Re: Strange syntax with select  (Melvin Davidson <melvin6925@gmail.com>)
List pgsql-general
On 12/25/2015 08:26 AM, Edson F. Lidorio wrote:
>
>

>>
>>
>> I'musing versionbelowPostgreSQL.
>>
>> PostgreSQL 9.4.5 on x86_64-unknown-linux-gnu, compiled by gcc (Debian
>> 4.9.2-10) 4.9.2, 64-bit
>>
>> --
>> Edson
>>
> via pgadmin not accept this syntax.
> You have any other way to do?

Should have added to previous post that this can be done using an
anonymous function:

http://www.postgresql.org/docs/9.4/interactive/sql-do.html

The caveat being anonymous functions cannot return anything. Still
something like the below:

DO
$$
DECLARE
     var_1 integer;
BEGIN
     SELECT INTO var_1 sum(cell_per) FROM cell_per;
     RAISE NOTICE 'Sum is %', var_1;
END
$$ LANGUAGE plpgsql;

NOTICE:  Sum is 193



--
Adrian Klaver
adrian.klaver@aklaver.com


pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Strange syntax with select
Next
From: Melvin Davidson
Date:
Subject: Re: Strange syntax with select