cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Insert String Using SQL Query

Former Member
0 Likes
852

Hi, EveryOne,

I tried to insert(update) a string data type using Fixed SQL Query as, for a example:

insert into Masters(MasterName) values([Param.1])

In html form I enter a value in field and press button to call the function. But if enter in the field a String value - nothing inserted in table but if I enter Number - everything works fine. I tried to use commas but the effect is the same.

Thnks,

Serj

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Sergey,

You have to wrap String and Date param values in single quotes. Try this:


insert into Masters(MasterName) 
values('[Param.1]')

Also, be sure you are using a "Command" Model SQL Query. A Fixed SQL Query will error when doing Inserts, Updates, and Deletes.

Former Member
0 Likes

Hi, Rian,

It works with help of Command but the String is not "English". In database I see '0?@5;L' instead of real value.

I was thought that connecting to database can be language independent.

Thnks,

Serj

Former Member
0 Likes

Hello Sergey,

Ryan's sql statement is right. The ' sign is used to mark the [Param.1] as a string.

The sql statement (connection) is language independent, but you have to make sure that you mark up strings and timestamps in the correct way.

In your first statement

Masters(MasterName) values([Param.1])

xMII will replace [Param.1] with the value you type in("yourvalue"). For strings("yourvalue") it will look like this

Masters(MasterName) values(yourvalue)

this should bring back a sql error. You can try it in another sql client.

Hope this help as an explanation.

Regards,

Martin

Answers (1)

Answers (1)

jamie_cawley
Product and Topic Expert
Product and Topic Expert
0 Likes

Using Ryan's suggestion, test the query in the template editor. If it works, then please supply the javascript you are using to set and run the query. If it does not work, please supply the database version and run a select statement against the table, change the content type to text/xml, and paste the column definitions of the xml in the thread.

Regards,

Jamie

Former Member
0 Likes

Hi, Sergey.

Almost certainly this has to do with UTF-8/encoding issues. There is an important combination of database settings, HTML page settings, and so on that affect this.

Also, it is important to be on the latest patch level of xMII (version 11.5 SR3), as I know there were some fixes in this area.

Best regards,

Rick