Обсуждение: Inserting exported bytea value

Поиск
Список
Период
Сортировка

Inserting exported bytea value

От
seiliki@so-net.net.tw
Дата:
I am trying to build SQL commands that insert values exported from a bytea column.  Output facilities do not escape
singlequotes for bytea column. As such, the built INSERT SQL can be invalid because single quotes can appear in values.
Forexample, the built (invalid) INSERT SQL command can look like this: 

INSERT INTO t1 VALUES ('ABC\\000C'DE');

Note the apostrophe between C and D.

Are there straight approaches to do this job using version 8.x?
Does the bytea hex export feature provided by version 9 help solve this problem?

Thank you in advance!

CN

Re: Inserting exported bytea value

От
Pavel Stehule
Дата:
Hello

why you don't use PQescapeBytea function ?

http://www.postgresql.org/docs/8.4/interactive/libpq-exec.html#LIBPQ-EXEC-ESCAPE-BYTEA

Regards
Pavel Stehule



2010/2/11  <seiliki@so-net.net.tw>:
> I am trying to build SQL commands that insert values exported from a bytea column.  Output facilities do not escape
singlequotes for bytea column. As such, the built INSERT SQL can be invalid because single quotes can appear in values.
Forexample, the built (invalid) INSERT SQL command can look like this: 
>
> INSERT INTO t1 VALUES ('ABC\\000C'DE');
>
> Note the apostrophe between C and D.
>
> Are there straight approaches to do this job using version 8.x?
> Does the bytea hex export feature provided by version 9 help solve this problem?
>
> Thank you in advance!
>
> CN
>
> --
> Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>