Anda di halaman 1dari 20

MapInfo Professional

Remote databases

Peter Horsbøll Møller, Systems Engineer


January 2009
Agenda

• Supported databases
• Data Source
• Connecting to database
• ODBC and OCI
• Creating a Data Source
• Configuring a Data Source
• Map Catalog
• Creating the Map Catalog
• Making a remote table mappable
• Working with the data
• Opening tables
• Refreshing
• Editing
• Saving
• Querying
• Questions and Answers
• Internet resources
Supported databases

• Spatial databases:
• Oracle 11g including Annotation Text (Spatial and Locator)
• Oracle 10g and 9iR2 (Spatial and Locator)
• SQL Server 2000 and 2005 with MapInfo SpatialWare

• Point and textual data:


• SQL Server 2000, 2005 and 2008
• MS Access
• Any ODBC database

• MapInfo 9.5 can read SQL Server 2008 Spatial thru Open
Universal Data.
ODBC and OCI

• ODBC – Open DataBase Connectivity


• OCI – Oracle Call Interface

• OCI is used when connecting to Oracle 9i, 10g or 11g for


spatial data
• ODBC is used when connecting to any ODBC compatible
database
• ODBC can also be used for connecting to older versions of
Oracle or when using non-spatial data
Connecting to the database

• If you have installed support for Oracle and you have a Oracle
client on your computer, you will be prompted to choose
between ODBC and Oracle Spatial when clicking File > Open
DBMS connection.
• Otherwise you will be asked to Select a Data Source directly.

• If Open DBMS Connection is disabled, you probably haven’t


installed support for DBMS. Choose this when installing
MapInfo Professional.

• The support for DBMS is “located” in two dll’s (midlodbc.dll and


midloci.dll) that can be copied into the MapInfo program folder
afterwards. They are specific to the MapInfo version.

• Note that MapInfo Professional 9.5 automatically installs


support for DBMS (ODBC and Oracle Spatial).
Creating a data source

• Open the dialog Select Data Source.


Can be accessed from the Open dialog
or from File > Open DBMS Connection.
• Select type of data source
• File Data Source
• Machine Data Source
• Click on the button New…
• Select the type of driver/database
• Enter a name/file name
• Data source will now be created
Configuring a Data Source
MS Access
• Depending on database/driver

MS SQL Server
Map Catalog

• The Map Catalog (MapInfo.MapInfo_MapCatalog) describes


spatial tables in the database with values like:
• Kind of spatial table, for example. XY, SpatialWare, Oracle
etc.
• Coordinate system
• Data bounds
• Symbol, default and per row
• Default view
Creating the Map Catalog

• Run the tool DBMS Catalog from Tools


> Tool Manager.
• Run Tools > DBMS Catalog > DBMS
Catalog and click Create Catalog.
• Select the data source pointing to the
database where you want to create the
Map Catalog
• The Map Catalog should now exist in
the database

• You can also create the catalog directly


in the database using SQL
Making a remote table mappable
• Select Table > Maintenance > Make
DBMS Table Mappable
• Select the table to make mappable
and click Open
• Now specify how the table should be
made mappable:
• Type
• X and Y coordinates
• Style
• Symbol
• Coordinate system
• Click OK
• Cancel the dialog Select DBMS
table if you don’t want to make more
tables mappable.
Opening a remote table

• Select File > Open


• Click on Open DBMS Connection
or select the open connection in
the File Type dropdown list
• Select the table to open and click
Open.
• Specify:
• Column
• Rows
• Access type
• Linked
• Live
• Where to place Tab file
Linked versus Live

• Linked:
• Data is copied to a MapInfo table
• Access to the database is only needed when saving or
refreshing -> working offline is possible
• Fast to work with when the data has been copied
• Duplicate data

• Live (with/without cache):


• Data is “always” read directly from the database
• Is using a temporary cache
• 9.5.0: Memory table
• 9.5.1: MapInfo table stored in the Windows Temp folder
• You always need access to the database
Refreshing

• Reloading data from the database can be done with Table >
Maintenance > Refresh DBMS Table...

• Refreshing a DBMS table


• Checks the database for changes
• Reapplies the query condition. Note that the query
conditions are static.
• If you have specified to filter using the current map or
current selection, this filter will always be applied to the
table. To specify a different map, you have to reopen the
table from the database.
Editing

• The remote table must contain a primary unique index


• In a view this column should be named MI_Prinx

• You can edit the data with every tool available in MapInfo
Professional

• When editing coordinates of a XY-coordinate table, the


coordinates are updated in the columns with the X and Y
coordinates in the database table
Saving

• Click Save Table to save the pending edits to the DBMS table

• When saving the edits to the database, MapInfo checks if


another user has updated the records you have changed. If so,
a dialog appears asking you to solve the conflict

• Saving changes offline can be done by closing the table.


MapInfo will ask how to store the pending edits:
• Disgard
 Save locally
• Save to the database
Querying - 1

• You can specify which records to retrieve from the database


• By attributes
Like and not like only available for text
columns

• By geography
Selection only available when a selection is
active
Current_Mapper only available when a
map is active
Object is only available for mappable
tables

• Query is performed when the table is opened the first time and
when the table is refreshed. Value of Current_Mapper and
Selection are static and not updated when the table is refreshed.
Querying - 2

• Write your own SQL statement


• Syntax depends on the database
• MapInfo Professional will “translate” certain expression when
passing the query to the database:
• Object
• Within
• Selection
• Current_Mapper
• …

• You can save and open queries


Questions and Answers

Q My Open DMBS connection is greyed out?


A You need to install the ODBC support
Q When I open a DBMS table, MapInfo tells me it is read-only?
A Make sure you are permitted to edit the table in the database and that the
table has a unique primary index – for views this column should be named
MI_PRINX
Q I’m not asked to choose between Oracle Spatial and ODBC?
A You either haven’t installed support for Oracle Spatial (OCI) or you haven’t
a Oracle client installed
Q My DBMS table can not be shown in a map?
A The table has probably not been made mappable
Q I have opened a DBMS table and made it mappable but it still can’t be added to
a map?
A You need to reopen the table from the database to make MapInfo
Professional read the mapping information
Q How do I see the columns with the coordinates inside MapInfo Professional?
A Create a view and add these columns twice (once with an alias), make the
view mappable and then open the view instead of the base table
Internet resources

• MapInfo Professional: www.mapinfo.com/mipro


• MapInfo MapBasic: www.mapinfo.com/mapbasic
• Encom Discover: www.encom.com.au/discover
• MapInfo SpatialWare: www.mapinfo.com/spatialware

• MapInfo FAQ: www.mapinfo.com/support/search-knowledge-base

• MapInfo-L discussion: groups.google.com/group/mapinfo-l


• MapInfo-L wiki: www.mapinfo-l.com/Wiki
Questions?

The Power of Insight

MapInfo Professional

Peter Horsbøll Møller


Systems Engineer
peter.moller@mapinfo.com

Anda mungkin juga menyukai