Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group