Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You 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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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