From: | WAGNERP(at)UWSTOUT(dot)EDU |
---|---|
To: | wwwadmin(at)wizard(dot)ca |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: [GENERAL] Apostrophes et al in a files with text attribute |
Date: | 1998-05-15 15:09:16 |
Message-ID: | 01IX224VFLZI016MA1@UWSTOUT.EDU |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> I have passed text via a Perl CGI to my database, and tried storing text
>
> into a field with the text attribute. Only problem is if there is an
> apostrophe in the string as in the word "can't"
> it will not INSERT.... hmm... isn't "isn't" text?
>
> hehehe.. anyways, what is the usual work around?
Since single quotes are the text delimiter, they need to be doubled up
within text. You want to end up with something like:
insert into table values ('This isn''t possible');
In Perl, if you have a variable containing your string, you can do
something like:
### --- Replace single quote with two single quotes for PostgreSQL
$value =~ s/\'/\'\'/g;
Hope this helps,
Paul
*************************************************************************
* Paul J. Wagner / Assistant Professor of Computer Science *
* Department of Mathematics, Statistics, and Computer Science *
* Harvey Hall, Room 202J; 715-232-5001 *
* University of Wisconsin - Stout work - wagnerp(at)uwstout(dot)edu *
* Menomonie, WI 54751 school - wagner(at)cs(dot)umn(dot)edu *
* www - http://www.mscs.uwstout.edu/~paul/home.html *
*************************************************************************
From | Date | Subject | |
---|---|---|---|
Next Message | The Hermit Hacker | 1998-05-15 20:14:31 | Re: [GENERAL] Distributed Database with PostgreSQL |
Previous Message | Thomas Good | 1998-05-15 14:05:22 | subscribe |