Re: unable to assign value to variable in plpgsql - Mailing list pgsql-novice

From David Johnston
Subject Re: unable to assign value to variable in plpgsql
Date
Msg-id 1392569507299-5792299.post@n5.nabble.com
Whole thread Raw
In response to Re: unable to assign value to variable in plpgsql  (Martin Steer <martinsteer@maxi.net.au>)
List pgsql-novice
Martin Steer wrote
> On Sun, Feb 16, 2014 at 04:22:28AM -0800, Chirag Mittal wrote:
>>Hi, I am trying to assign number of row as integer Tried 1 maz int
:=(SELECT
>>count(col1) FROM table WHERE col1 = quote_literal(in val1)); Tried 2
EXECUTE
>>'SELECT count(col1) FROM table WHERE col1 = quote_literal(val1) INTO maz';
>>getting error INTO Regards Chirag
>
> select count(*)
> into maz
> from tablename
> where col1 = 'val1';
>
> maz int := count(*) from tablename where col1 = 'val1';
>
> M.

Note that if val1 is a variable you do not use quotes. Only when it is a
literal/constant.  Using quotes makes it into a literal/constant.

David J.





--
View this message in context:
http://postgresql.1045698.n5.nabble.com/unable-to-assign-value-to-variable-in-plpgsql-tp5792281p5792299.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.


pgsql-novice by date:

Previous
From: David Johnston
Date:
Subject: Re: unable to assign value to variable in plpgsql
Next
From: Chirag Mittal
Date:
Subject: Re: unable to assign value to variable in plpgsql