I made a Query in Mapbasic like :
Dim query As String
query = "Select * from some_table"
How to run query to form table? Is it possible to save selected value in variable without forming table?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityYou can just run the SQL command right in the MapBasic code:
Select * from some_table into mySelection
If you do need to store the SQL query in a string (dynmic SQL string etc) you can execute it using RunCommand
Dim query As String
query = "Select * from some_table into mySelection"
Run Command query
In order to get the values from the table you need to use Fetch
Dim value as String
Fetch First From mySelection
value = mySelection.{ColumnName}
You will have to write a loop using Fetch First and Fetch Next to loop over all the records to do something with each one.