[erlang-questions] database retrieve problem

Hynek Vychodil hynek@REDACTED
Sun Mar 28 18:58:35 CEST 2010


When I look at your error message and code then I easily can guess,
that badmatch is on row

[Results] = odbc:sql_query(Conn, "SELECT * FROM marks where id=1")

so I look at documentation and bingo! It is. I strongly recommend you
try code in shell and look what code returns when you don't want read
documentation. You should try it in shell even have read
documentation. Above row should be

{selected, _Cols, [Result]} = odbc:sql_query(Conn, "SELECT * FROM
marks where id=1")

or

{selected, _Cols, Results} = odbc:sql_query(Conn, "SELECT * FROM marks
where id=1")

On Sun, Mar 28, 2010 at 9:37 AM, NavaTux <navaneethanit@REDACTED> wrote:
> I wanna to use the query to retrieve some results from the database,so
> i used these lines
>
> event(continue) ->
>        [Name] = wf:q(no_id),
>        Message = wf:f("The Result is~p", [Name]),
>        ConnString = "DSN=mysqldb",
>        {ok, Conn} = odbc:connect(ConnString, []),
>        [Results] = odbc:sql_query(Conn, "SELECT * FROM marks where id=1"),
>        io:format("~p",[Results]),
>        wf:flash([Results]),
>  ok;
> event(_) -> ok.
>
> but i am unable to get the output,Here continue is the postback for
> button,here what goes wrong?
>
> I am getting output in my terminal is
>
>
> =INFO REPORT==== 28-Mar-2010::21:56:22 ===
> ERROR: error
> {badmatch,{selected,["id","tamil","english","maths","science"],
>                    [{1,45,55,67,89}]}}
> [{web_index,event,1},
>  {wf_handle_postback,run_module_event,2},
>  {wf_handle_postback,handle_normal_request,3},
>  {wf_inets,do,3},
>  {httpd_response,traverse_modules,2},
>  {httpd_response,generate_and_send_response,1},
>  {httpd_request_handler,handle_response,1},
>  {gen_server,handle_msg,5}]
>
>
> id,tamil,english,maths,science are database fields....
>
> please help me
> as well as i wanna know how to flash the output that i retrieved from
> the database in my webpage..
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>



-- 
--Hynek (Pichi) Vychodil

Analyze your data in minutes. Share your insights instantly. Thrill
your boss.  Be a data hero!
Try GoodData now for free: www.gooddata.com


More information about the erlang-questions mailing list