user13428634
user13428634

Reputation:

I want to get input from the user in Erlang and add it to the database

insert(Id, Country, Province, City, Street, PostCode) ->
  odbc:start(), 
  {ok,Seve} = odbc:connect("DSN=test", []),
  io:fwrite("~p", odbc:param_query(Seve,"INSERT INTO Address (ID, COUNTRY, 
                  PROVINCE, CITY, STREET, POST_CODE) VALUES(?, ?, ?, ?, ?, ?)"

I want to get input from the user in Erlang and add it to the database.

Now where do I use the values taken at the input?

Upvotes: 1

Views: 73

Answers (1)

Hitesh Vaghani
Hitesh Vaghani

Reputation: 1362

To take the user of input use following function.

{ok, Input} = io:read("Enter a params: ").

Edit, Make sure Params' input is like [1,3,4,...]

odbc:param_query(Seve,"INSERT INTO Address (ID, COUNTRY, 
                  PROVINCE, CITY, STREET, POST_CODE) VALUES(?, ?, ?, ?, ?, ?)", Params).

Upvotes: 1

Related Questions