Question on inserting non-ascii strings - Mailing list pgsql-general

From Steven Lembark
Subject Question on inserting non-ascii strings
Date
Msg-id 20090514112533.16baf3e8@bird.wrkhors.com
Whole thread Raw
Responses Re: Question on inserting non-ascii strings  (Sam Mason <sam@samason.me.uk>)
List pgsql-general
Using Postgres 8.3 with DBI 1.607, DBD::Pg 2.12.0, perl v5.10.0,

I am trying to insert the medline database
contents, which include non-ascii char's,
hopefully using a prepared query.

Playing with the locale, encoding,
client_encoding, standard_conforming_strings,
leaves me able to insert values using one-off
querys, but I need to find out the correct way
to handle these using prepared querys (currently
using C, SQL_ASCII, SQL_ASCII, off).

For example, given:

    create table foo ( bar varchar(255) );

and the author's name

    "P\x8FAZEK"

Setting the client_encoding to "SQL_ASCII"
does not help: the values can be inserted
via

    E'P\x8FAZEK'

but E'$1' will simply insert the "$1" literal
into the table.

Using

    convert_from( $1, 'SQL_ASCII' ) gets

gets the values input, but with a warning.

Q: Is there any combination of locale, encoding,
   client_encoding or functions that will allow
   me to insert values with these escape sequences
   without getting the warnings?

Trying this in psql with various combinations of
prepares statements leaves me unable to use
convert_from with a varchar argument (requires
bytea).

If there is an example in the doc's I'd appreciate
a link to it.

thanks

--
Steven Lembark                                            85-09 90th St.
Workhorse Computing                                 Woodhaven, NY, 11421
lembark@wrkhors.com                                      +1 888 359 3508

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Failure during initdb - creating dictionaries ... FATAL: could not access file "$libdir/libdict_snowball": No such file or directory
Next
From: "George Kao"
Date:
Subject: Re: how to extract data from bytea so it is be used in blob for mysql database