Erlang/OTP Forums

Author Message

<  Erlang  ~  MySql update query

ishmael
Posted: Thu Oct 23, 2008 8:56 am Reply with quote
Joined: 23 Jul 2008 Posts: 9 Location: RSA
Hi,

I am having troubles quering a MySql DB vr3.51. I want to update fields of a table on the erlang shell.
has anybody worked with MySql on erlang who can help?
Code:
1>odbc:start().
2> {ok, Ref} = odbc:connect("Driver={MySQL ODBC 3.51 Driver};Server=localhost;Port=3306;Database=urec;User=;Password=;Option=3;", []).
3>Value1 = 1.
4>Time = "02:02:02".
5> UpdateQuery = "update urec.mdp set Sms_p_sub_Count= '" ++ integer_to_list(Value1) ++ "' ++ where Datetime= '"++ Time ++"'".
6> {ok, _} = odbc:sql_query(Ref, UpdateQuery9). % gives error ** exception error: no match of right hand side value {error,connection_closed}
View user's profile Send private message
Roux Viljoen
Posted: Tue Nov 04, 2008 11:14 am Reply with quote
Joined: 04 Nov 2008 Posts: 3 Location: London
Hi ishmael,

I believe its the line where you define your query.
Try this :
Code:

UpdateQuery = "update urec.mdp set Sms_p_sub_Count= '" ++ integer_to_list(Value1) ++ "' where Datetime= '"++ Time ++"';",


That should clear it up. You had a '++' inside your query-string. You should enable highlighting if you are using emacs, that will make it easier for you to spot.

Also, if Sms_p_sub_Count is an integer field, I suggest you remove the single quotes around its variable.

Then it should look like this:

Code:

UpdateQuery = "update urec.mdp set Sms_p_sub_Count= " ++ integer_to_list(Value1) ++ " where Datetime= '"++ Time ++"';",


I hope that helps Smile


Roux
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum