Re: "'" in SQL INSERT statement
От | Albert REINER |
---|---|
Тема | Re: "'" in SQL INSERT statement |
Дата | |
Msg-id | 20010125184237.A1034@frithjof обсуждение исходный текст |
Ответ на | "'" in SQL INSERT statement (Markus Wagner <wagner@imsd.uni-mainz.de>) |
Список | pgsql-sql |
Saluton! On Thu, Jan 25, 2001 at 11:12:34AM +0100, Markus Wagner wrote: ... > Some of the data are strings containing the apostrophe "'" which I use > as string delimiter. > > How can I put these into my database using the INSERT statement? I always use this sub: # # This sub adapted from sub TEXT of mmusic by ChLorenz@csi.com, using # advice from the pgsql-novice mailing list(David Rugge, 1 Aug 1999). # # Do the necessary quoting for strings. # sub stdstr { my $or = $_[0]; returnundef unless (defined($or)); $or =~ s /\\/\\\\/g; # mmusic doesn't have this, nor does D. Rugge. $or =~s /\'/\\\'/g; $or =~ s /\"/\\\"/g; $or =~ s /%/\\%/g; # mmusic doesn't have this. return $or; } Obviously you also need to escape the \. I no longer remember why " and % are needed, but I certainly did have some reason then. Albert. -- -------------------------------------------------------------------------- Albert Reiner <areiner@tph.tuwien.ac.at> Deutsch * English * Esperanto * Latine --------------------------------------------------------------------------
В списке pgsql-sql по дате отправления: