From: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: varchar for loops possible? |
Date: | 2012-05-21 10:24:56 |
Message-ID: | jpd55o$o60$2@reversiblemaps.ath.cx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2012-05-18, J.V. <jvsrvcs(at)gmail(dot)com> wrote:
> I have a table with a varchar column.
>
> I want to select the distinct values from this column and loop through
> them (using as a variable) in a raise notice statement and also in an
> update statement.
>
> I have not been able to do this trying over 100 things in the last two
> hours. I could not find an example on google.
>
> for tmp_var in select distinct(value) from mytable where
> value2='literal'
> loop
> raise notice 'I want to print a message here - the tmp_var is
> [' || tmp_var || ']';
raise notice does not take a string argument,
it takes a string-literal-like argument.
you can't use a string expression as the argument to raise notice.
do it like this:
raise notice 'the tmp_var is [%]', tmp_var;
I think this restriction is because the psql compiler needs to parse
the string at compile time to produce the raise-notice bytecode,
--
⚂⚃ 100% natural
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Sullivan | 2012-05-21 10:59:55 | Re: Concerning about Unicode-aware string handling |
Previous Message | Jasen Betts | 2012-05-21 10:13:03 | Re: Libpq question |