1 (edited by mathmathou 2015-12-07 07:33:49)

Topic: Don't laugh....

Hello all,


Well, I am a bit ashamed to ask such a question, but I have problems INSERTING..... Integers.... smile


Can someone show me what the correct syntax is ?


if main_cat > 0 then SQLExecute('UPDATE asset SET id_main_cat=' main_cat ' WHERE id=' current_asset_id);

main_cat and current_asset_id being INTEGERs of course AND the table fields are also SET to INTEGER.


Thanks in advance.


Cheers


Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Don't laugh....

You are trying to insert the value ' main_cat ' which is alphanumeric in an integer field.... maybe it should be +main_cat'

Re: Don't laugh....

if main_cat > 0 then SQLExecute('UPDATE asset SET id_main_cat='+ IntToStr(main_cat) + ' WHERE id='+ IntToStr(current_asset_id));
Dmitry.

Re: Don't laugh....

Thanks for the replies.

I will  try that tomorrow morning  (it is 1 am here ).

But wath bothers me is the IntToStr because I am trying to insert  in a INTEGER databse field.  I do not understand why convert the integer into string before inserting into... integer  smile

I Will see that tomorrow morning first thing.

Cheers

Mathias

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Don't laugh....

mathmathou
Because the SQL query is just text, it's ok using IntToStr for Integer values in sql queries.

Dmitry.

Re: Don't laugh....

Hello all,

I think I forgot to answer this post to mention it worked of course.


But this still bothers me to convert Integer to strings before saving them into integer fields in database smile smile smile

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor

Re: Don't laugh....

It might be related to your variable maint_cat, if it is string, then you have to convert it, if it is integer, you should not need it... did you try?

Re: Don't laugh....

Hello tcoton,


That's the part I don't understand : the variable is integer and the database field is also set to integer.

But with Dmitry's trick it works smile

In fact my question was :
when I want to insert TEXT, I escape the variable in the SQL Query with :

"'+text_variable+'"

what is the correct escape sequence for numbers ?

I'm a very good housekeeper !
Each time I get a divorce, I keep the house

Zaza Gabor