I was hoping there was a way to give a timestamp from erlang using the output of erlang:now() but thanks for the information about strings.<br>Also I'm using prepare/execute because I assume it is faster than pquery and because
<br>pquery hangs/timeouts for the queries I like to do.<br><br><br>I'll put this info in the jungerl bug tracker on sourceforge also:<br><br>For pgsql from jungerl (checked out Dec 3 2007), using PostGres 8.0.13/PostGis
1.1.4<br><br>psql> create table my_table (timestamp_column timestamp);<br>psql> create table test_gps (message_id BIGSERIAL,<br> occurrence TIMESTAMP,<br> device_id VARCHAR,<br> location GEOMETRY,<br> speed REAL,
<br> heading REAL,<br> info VARCHAR);<br><br><br>Then in erlang using jungerl's pgsql:<br><br>Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [hipe] [kernel-poll:false]<br><br>Eshell V5.5.5 (abort with ^G)
<br><br>1> {ok, Db} = pgsql:connect("localhost", "tracker", "dave", "").<br>Params: [{secret,{5521,1197959615}},<br> {{parameter,"TimeZone"},"US/Eastern"},
<br> {{parameter,"session_authorization"},"dave"},<br> {{parameter,"server_version"},"8.0.13"},<br> {{parameter,"server_encoding"},"SQL_ASCII"},
<br> {{parameter,"is_superuser"},"off"},<br> {{parameter,"integer_datetimes"},"off"},<br> {{parameter,"DateStyle"},"ISO, MDY"},<br> {{parameter,"client_encoding"},"SQL_ASCII"}]
<br>{ok,<0.33.0>}<br>2> pgsql:prepare(Db, insert_point, "insert into test_gps (device_id, speed, heading, info, location) values ($1,$2,$3,$4,GeomFromText($5,-1))").<br><br>=ERROR REPORT==== 5-Dec-2007::12:09:08 ===
<br>Error in process <0.33.0> with exit value: {{badrecord,dict},[{dict,get_slot,2},{dict,fetch,2},{lists,map,2},{pgsql_proto,idle,2}]}<br><br>** exited: {{badrecord,dict},<br> [{dict,get_slot,2},<br> {dict,fetch,2},
<br> {lists,map,2},<br> {pgsql_proto,idle,2}]} **<br><br>3> pgsql:prepare(Db, insert_point, "insert into my_table (timestamp_column) values ($1)").
<br>timeout<br>4> pgsql:pquery(Db, "insert into my_table (timestamp_column) values ($1)", ["2000-01-01 12:43:23"]). <br>timeout<br>5> pgsql:pquery(Db, "insert into test_gps (device_id, speed, heading) values ($1,$2,$3)", ["abc", 45, 54]).
<br>timeout<br><br><br>NOTE: The pgsql:prepare and a subsequent pgsql:execute works in the pgsql from ejabberd-modules. The pgsql:pquery calls always time out. pgsql:squery calls usually work though.<br><br><br><br><div class="gmail_quote">
On Dec 5, 2007 8:41 AM, Daniel Caune <<a href="mailto:daniel.caune@ubisoft.com">daniel.caune@ubisoft.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">>In the current postgresql driver for erlang (I'm using the<br>ejabberd-module >one because that's the one I got to work), how does one<br>specify TIMESTAMP >values?<br>><br>>ie if I do
<br>><br>>pgsql:prepare(Db, my_insert, "insert into foo_table (timestamp_column)<br>>values ($1)").<br>><br>>what should I put in the subsequent call to<br>><br>>pgsql:execute(Db, my_insert, [?????])
<br>><br><br></div>You should be able to write something like this:<br><div class="Ih2E3d"><br>pgsql:prepare(Db, my_insert, "insert into foo_table (timestamp_column)<br></div>values ($1::timestamp)").<br>pgsql:execute(Db, my_insert, ["YYYY-MM-DD HH24:MN:SS"]).
<br><br>I'm not sure that "::timestamp" is very useful as I suppose PostgreSQL<br>to do the conversion by its own.<br><div class="Ih2E3d"><br>>P.S. I think the Junglerl pgsql driver is broken for prepared
<br>statements.<br><br></div>Did you try pgsql:pquery? It works fine.<br><br>--<br><font color="#888888">Daniel<br></font></blockquote></div><br>