Hi everyone
I have a problem in development :
DataBase:
"PostgreSQL 9.3.4 on x86_64-unknown-linux-gnu, compiled by gcc (GCC) 4.4.7
20120313 (Red Hat 4.4.7-4), 64-bit"
Table:
CREATE TABLE disp_analyze_test
(
bill_code character varying(50) NOT NULL,
province1 character varying(30) NOT NULL,
send_date timestamp(0) without time zone NOT NULL,
send_site character varying(30) NOT NULL,
dispatch_site character varying(30) NOT NULL,
scan_site character varying(30),
province2 character varying(30),
area_name character varying(50),
superior_site character varying(30),
scan_date timestamp(0) without time zone,
sign_date timestamp(0) without time zone NOT NULL,
sx numeric(10,2),
CONSTRAINT disp_analyze_test_pkey PRIMARY KEY (bill_code)
)
WITH (
OIDS=FALSE
);
ALTER TABLE disp_analyze_test
OWNER TO postgres;
Code:
Str_Sql = "select * from disp_analyze_test where bill_code = $1 limit
10",
Parameter = "500009413003",
{ok,FieldsData,ValuesData} = boss_db:execute(Str_Sql,[Parameter]),
F9 = [list_to_atom(binary_to_list(Field)) ||
{_,Field,_,_,_,_}<-FieldsData],
Result = lists:map(
fun(Value)->
lists:zip(F9,tuple_to_list(Value))
end,ValuesData),
{json,[{data,Result}]}.
Error:
20:02:37.911 [error] Unhandled Error: exit:{json_encode,{bad_term
,{{2014,5,20},{20,25,47.0}}}}. Stacktrace:
[{mochijson2,json_encode,2,[{file,"src/mochijson2.erl"},{line,163}]},{mochijson2,'-json_encode_proplist/2-fun-0-',3,[{file,"src/mochijson2.erl"},{line,181}]},{lists,foldl,3,[{file,"lists.erl"},{line,1248}]},{mochijson2,json_encode_proplist,2,[{file,"src/mochijson2.erl"},{line,184}]},{mochijson2,'-json_encode_array/2-fun-0-',3,[{file,"src/mochijson2.erl"},{line,171}]},{lists,foldl,3,[{file,"lists.erl"},{line,1248}]},{mochijson2,json_encode_array,2,[{file,"src/mochijson2.erl"},{line,173}]},{mochijson2,'-json_encode_proplist/2-fun-0-',3,[{file,"src/mochijson2.erl"},{line,181}]}]
inside CB Shell:
(shixiao@yangxianbindeMacBook-Pro)7>
(shixiao@yangxianbindeMacBook-Pro)7> StrSql = "select * from
disp_analyze_test limit 1;".
"select * from disp_analyze_test limit 1;"
(shixiao@yangxianbindeMacBook-Pro)8> StrSql1 = "select * from
disp_analyze_test where bill_code=$1 limit 1;".
"select * from disp_analyze_test where bill_code=$1 limit 1;"
(shixiao@yangxianbindeMacBook-Pro)9> lib_db:json_data_sql(StrSql).
{json,[{data,[[{bill_code,<<"100004533361">>},
{province1,<<229,185,191,228,184,156,231,156,129>>},
{send_date,<<"2014-05-20 20:12:13">>},
{send_site,<<229,141,151,230,157,145,229,133,172,229,143,
{area_name,<<229,141,142,229,141,151,231,137,135,229,140,
186>>},
{superior_site,<<232,153,142,233,151,168,229,136,134,230,
139,168,...>>},
{scan_date,<<"2014-05-21 08:46:06">>},
{sign_date,<<"2014-05-21 13:10:57">>},
{sx,<<"4.41">>}]]}]}
(shixiao@yangxianbindeMacBook-Pro)10>
lib_db:json_data_sql(StrSql1,"500009413003").
Str_Sql="select * from disp_analyze_test where bill_code=$1 limit 1;"
Param="500009413003"
{json,[{data,[[{bill_code,<<"500009413003">>},
{province1,<<230,181,153,230,177,159,231,156,129>>},
{send_date,{{2014,5,20},{20,25,47.0}}},
{send_site,<<230,133,136,230,186,170,229,133,172,229,143,
184>>},
{dispatch_site,<<229,184,184,229,185,179,229,133,172,229,
143,184>>},
{scan_site,<<229,184,184,229,185,179,229,133,172,229,143,
184>>},
{province2,<<229,185,191,228,184,156,231,156,129>>},
{area_name,<<229,141,142,229,141,151,231,137,135,229,140,
186>>},
{superior_site,<<232,153,142,233,151,168,229,136,134,230,
139,168,...>>},
{scan_date,{{2014,5,22},{16,4,38.0}}},
{sign_date,{{2014,5,25},{12,23,20.0}}},
{sx,<<"68.31">>}]]}]}
I found send_date fields in SQL statement has parameters, resulting in a
slight difference:
No argument( boss_db:execute("select * from bill") ):
{send_date,<<"2014-05-20 20:12:13">>}
has arguments( boss_db:execute("select * from bill where bill_code like
$1",["123456"]):
{send_date,{{2014,5,20},{20,25,47.0}}},
Thanks a lot!
--
You received this message because you are subscribed to the Google Groups
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit
https://groups.google.com/d/msgid/chicagoboss/32b38a1a-4e95-444d-a947-9e63f07b2be3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.