pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Fabio Mancinelli <mancinel@univaq.it>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] ' escape
Date: Mon, 7 Dec 1998 18:04:19 +0200
Message-ID: <l0311070cb291ab8e015a@[147.233.159.109]> (raw)
In-Reply-To: <Pine.GSO.3.96.981207162742.896B-100000@brutus>

At 17:31 +0200 on 7/12/98, Fabio Mancinelli wrote:


> I have a question. When I create a table I cannot use any escape to put a
> ' character in the default field definition.
>
> CREATE TABLE Test (name varchar(128) default 'Something with '' into');
>
> Fails. I've tried also other alternatives :
> default "Something with ' into"
> default "Something with '' into"
> default 'Something with \' into'
> default 'Something with \27 into'
> default 'Something with \0x27 into'
>
> Everything fails.

Interesting bug.

As a workaround, if you really need that default value, define a simple SQL
function which returns it:

testing=> CREATE FUNCTION specialValue() RETURNS varchar
testing-> AS 'SELECT ''a value with '''' in it''::varchar'
testing-> LANGUAGE 'sql';
CREATE
testing=> SELECT specialValue();
specialvalue
--------------------
a value with ' in it
(1 row)

Now define your table. Here is an example:

testing=> CREATE TABLE test6 (
testing->   id int,
testing->   name varchar(128) DEFAULT specialValue()
testing-> );
CREATE
testing=> INSERT INTO test6 (id) values (1);
INSERT 932640 1
testing=> SELECT * FROM test6;
id|name
--+--------------------
 1|a value with ' in it
(1 row)

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (9+ messages)  latest in thread

Message-ID: <l0311070cb291ab8e015a@[147.233.159.109]>
Permalink:  ../l0311070cb291ab8e015a@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l0311070cb291ab8e015a@[147.233.159.109]

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: herouth@oumail.openu.ac.il, mancinel@univaq.it
  Subject: Re: [SQL] ' escape
  In-Reply-To: <l0311070cb291ab8e015a@[147.233.159.109]>
  References: <Pine.GSO.3.96.981207162742.896B-100000@brutus> <l0311070cb291ab8e015a@[147.233.159.109]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox