failed to insert erlang list as binary to pgsql via jungerl driver
Posted: 16 June 2007 01:33 PM   [ Ignore ]
Newbie
Rank
Total Posts:  1
Joined  2007-06-16

I do not know if it is a rigth place to ask, but i hope so smile

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'\0'


But, me failed to understand how I can do this.
Please, suggest an idea to me how to resolve this.
Thanks.

Profile
 
 
Posted: 06 July 2007 02:35 PM   [ Ignore ]   [ # 1 ]
Moderator
Avatar
RankRankRankRank
Total Posts:  107
Joined  2006-11-13

This is not the right place to ask such question (not related to CEAN)
please use erlang-question mailing list instead.

Profile