From: | Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il> |
---|---|
To: | Fabio Mancinelli <mancinel(at)univaq(dot)it> |
Cc: | pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: [SQL] ' escape |
Date: | 1998-12-07 16:04:19 |
Message-ID: | l0311070cb291ab8e015a@[147.233.159.109] |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Sascha Schumann | 1998-12-07 18:19:10 | Re: [SQL] Odd characters in inserted data... |
Previous Message | Fabio Mancinelli | 1998-12-07 15:31:31 | ' escape |