VERIFIED SOLUTION i
X

How to insert objects and data from a query of one table into another table in MapBasic

UPDATED: March 24, 2017


How can objects and data be inserted from a query to another table?

Below is some sample MapBasic code that demonstrates inserting records from a query into another table:

'demonstrates how to insert object and data from a query to another table

'variables to hold values from the query
dim strTheName as string
dim objTheObj as object

'clean start
close all

'two tables with maps...
create table bob (thename char(30)) file "c:\bob.tab" type native
create table bobX (thename char(30)) file "c:\bobX.tab" type native
Create Map For bob
Create Map For bobX

'insert new row\object in first table
insert into bob (thename, obj) values ("my_name" , createpoint (0,0))

'query first table
Select thename from bob into bobQ
fetch first from bobQ

'move obj and data from query to second table

'this next line doesn't work, table.column can't be used inside the values clause
'insert into bobX (thename, obj) values (bobQ.thename, bobQ.obj) 

'So, use these variables instead:
strTheName = bobQ.thename
objTheObj = bobQ.obj

insert into bobX (thename, obj) values (strTheName, objTheObj)

Downloads

  • No Downloads