Topic: Is Record ID a String in a table

Hello,
The following works to change a table field without opening the record in a window.
SQLExecute('UPDATE Staff SET Location = "Away" where id =' +inttostr(form1.tablegrid1.dbItemID));
The above shows that the record ID in a table is a string, not an integer.
Selecting an individual record for printout in a report looks like the statement below.
WHERE employees.id = $id;
Why is a single record id written in different ways whether it is in a table or a report?
Is there some sort of rule to apply to know when to use the different ways of doing this?
Dumb question in know but I have to ask.
Thanks,
David

Re: Is Record ID a String in a table

David,
Id's are integers. dbitemid references the id in a tablegrid and is an integer. SqlExecute needs a string for the SQL statement. That's why the dbitemId needs to be converted to string  with the inttostr() function inside the SqlExecute statement.

SQLExecute('UPDATE Staff SET Location = "Away" where id =' +inttostr(form1.tablegrid1.dbItemID));

SqlValue can also be used in place of dbitemId. It is already converted to a string and no need to use inttostr() function:

SQLExecute('UPDATE Staff SET Location = "Away" where id =' +form1.tablegrid1.sqlvalue)

;

Hope this helps.

Re: Is Record ID a String in a table

Hello ehwagner,
thank you for your help to understand this.
Regards,
David

Re: Is Record ID a String in a table

I never ever had to convert the id into string in my SQL queries and it always works!

Re: Is Record ID a String in a table

tcoton,
Not sure how that is possible. If you remove the inttostr() on the dbitemid from David's example above, you will get an "Incompatible Types" error.