inserting boolean values in dynamic queries

From: "Raphael Bauduin" <rblists(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: inserting boolean values in dynamic queries
Date: 2008-09-18 09:49:26
Message-ID: f5227160809180249q508b7a1rf11795a5b38b9f41@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I'm building a dynamic query as described at
http://www.postgresql.org/docs/8.3/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN
:

EXECUTE 'UPDATE tbl SET '
|| quote_ident(colname)
|| ' = '
|| quote_literal(newvalue)
|| ' WHERE key = '
|| quote_literal(keyvalue);

It works fine, except when I want to include a boolean value: the cast
of newvalue from boolean to text causes problem.

I can change my code and work with 't' and 'f' values as text, but
wondered if there wasa way to use boolean values in a dynamically
generated query.

Thanks

Raphaël

--
Web database: http://www.myowndb.com
Free Software Developers Meeting: http://www.fosdem.org

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Rafael Domiciano 2008-09-18 11:49:20 Re: Doubts about FK
Previous Message Steve Midgley 2008-09-18 04:10:28 Re: surrogate vs natural primary keys