[erlang-questions] failed to insert erlang list as binary to pgsql via jungerl driver

Oleg Palij o.palij@REDACTED
Sun Jun 17 10:06:46 CEST 2007


Hi, all!

1> {ok, DBRef}=pgsql:connect("xx", "xxx", "xx","xx",5432).
{ok,<0.31.0>}
2> pgsql:squery(DBRef, ["CREATE TABLE test (list BYTEA);"]).
{ok,["CREATE TABLE"]}
3> pgsql:squery(DBRef, ["INSERT INTO test (list) VALUES ('",term_to_binary(["e1","e2"]),");"]).
{ok,[{error,[{severity,'ERROR'},
             {code,"08P01"},
             {message,"invalid message format"},
             {file,"pqformat.c"},
             {line,689},
             {routine,"pq_getmsgend"}]}]}

as I understand that is becouse of 0 characters in binary:

2> term_to_binary(["e1","e2"]).
<<131,108,0,0,0,2,107,0,2,101,49,107,0,2,101,50,106>>

as pgsql docs say that 0 character should be escaped with E'\\000'
But, me failed to understand how I can do this. 
Please, suggest an idea to me how to resolve this. 
Thanks.

-- 
ISC Pridn railway, System Administrator
e-mail: o.palij@REDACTED
xmpp://malik@jabber.te.ua



More information about the erlang-questions mailing list