Re: Strange syntax with select

From: Melvin Davidson <melvin6925(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: "Edson F(dot) Lidorio" <edson(at)openmailbox(dot)org>, Charles Clavadetscher <clavadetscher(at)swisspug(dot)org>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Strange syntax with select
Date: 2015-12-25 18:57:14
Message-ID: CANu8FixWZy-DRhw3ZBQCrUrH8xWxP71pKYanFnRJ-c_2Tb_mSA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Edson,

I've attached a script that shows how to use bash to assign a variable from
a SQL statement.

On Fri, Dec 25, 2015 at 12:48 PM, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:

> 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(dot)klaver(at)aklaver(dot)com
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

--
*Melvin Davidson*
I reserve the right to fantasize. Whether or not you
wish to share my fantasy is entirely up to you.

Attachment Content-Type Size
get_trans_min_cnt.sh application/x-sh 794 bytes

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jim Nasby 2015-12-25 19:58:32 Re: efficient math vector operations on arrays
Previous Message Adrian Klaver 2015-12-25 17:48:52 Re: Strange syntax with select