0

I have a value stored in a variable. How can I write this value to a table (for example into Row2 Column4) using Mapbasic?

1

First you need to select the row you want to update:

Select * from MyTable where MyColumn = "MyData" into ToUpdate

Then update the selection with the data from your variable, in this case varMyValue:

Update ToUpdate set Col4 = varMyValue

Alternatively, you can update by RowID although that is not recommended as this can cause problems when a table hasn't been packed etc, so it is better to select the specific row you want to update first. If you do want to update by RowID it is just a slight alteration to the update statement, but again, it is best to avoid this:

Update ToUpdate set Col4 = varMyValue where RowID = 2

I would highly recommend consulting the MapBasic Reference Guide (available online, just google it) and looking specifically at how the Update statement works. It is also a great reference to get to know all of the available commands in the MapBasic language.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.