Question about Update Table

30 views
Skip to first unread message

Evgeny Kleiman

unread,
Dec 19, 2024, 9:55:25 AM12/19/24
to MapInfo-L
I want update  field comment in some row of table Lines . I wrote in my program
Update Lines Set comment = commentVal Where userid = int(id)
Here userid is a field of integer type and there is index according this field
So I get an error message:
 "Cannot perform this operation on field userid"
But if I run the same statement in MapBasic window of MapInfo:
 Update Lines Set comment = "test" Where userid = 10002
then it works fine.
I do not understand what's wrong?
Currently I found the following way. Because a segment of Lines is selected then I can  use the following code:
Select * From Selection Into CurData
 Update CurData Set comment = commentVal 
 Commit Table Lines
 Close Table CurData
But I still want to know what is wrong with my previous code.

Uffe Kousgaard

unread,
Dec 19, 2024, 11:18:14 AM12/19/24
to mapi...@googlegroups.com
Hi,

The "id" in your first statement is most likely a variable and not a field?
I think that is the issue.

You can do like this instead:

dim S as string
S = "Update Lines Set comment = " + commentVal +" Where userid = " + str$(id)
run command S

disclaimer: Untested !

Regards
Uffe Kousgaard
--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/mapinfo-l/baffb6d8-a7d8-41b3-91cd-6d6f5231a0f3n%40googlegroups.com.

Evgeny Kleiman

unread,
Dec 19, 2024, 11:30:37 AM12/19/24
to MapInfo-L
Thank you, it really works with minor change:
S = "Update Lines Set comment = """ + commentVal +""" Where userid = " + str$(id)

Reply all
Reply to author
Forward
0 new messages