Use this stored procedure to import a shape file to a database that is enabled for spatial operations.
>>-DB2GSE.ST_IMPORT_SHAPE--(--file_name--,----------------------> >--+-input_attr_columns-+--,--srs_name--,--+-table_schema-+-----> '-null---------------' '-null---------' >--,--table_name--,--+-table_attr_columns-+--,------------------> '-null---------------' >--+-create_table_flag-+--,--+-table_creation_parameters-+--,---> '-null--------------' '-null----------------------' >--spatial_column--,--+-type_schema-+--,--+-type_name-+--,------> '-null--------' '-null------' >--+-inline_length-+--,--+-id_column-+--,-----------------------> '-null----------' '-null------' >--+-id_column_is_identity-+--,--+-restart_count-+--,-----------> '-null------------------' '-null----------' >--+-commit_scope-+--,--+-exception_file-+--,-------------------> '-null---------' '-null-----------' >--+-messages_file-+--,--msg_code--,--msg_text--)-------------->< '-null----------'
If you specify the optional file extension, specify either .shp or .SHP. DB2 Spatial Extender first looks for an exact match of the specified file name. If DB2 Spatial Extender does not find an exact match, it looks first for a file with the .shp extension, and then for a file with the .SHP extension.
See Usage notes for a list of required files, which must reside on the server machine. The stored procedure, which runs as a process that is owned by the DB2 instance owner, must have the necessary privileges on the server to read the files.
The data type of this parameter is VARCHAR(256).
N(COLUMN1,COLUMN5,COLUMN3,COLUMN7)
If a column name is not enclosed in double quotation marks,
it is converted to uppercase. Each name in the list must be separated
by a comma. The resulting names must exactly match the column names
in the dBASE file.P(1,5,3,7)
Columns are numbered beginning with 1. Each number in
the list must be separated by a comma.The data type of this parameter is VARCHAR(32K).
The spatial column will not be registered. The spatial reference system (SRS) must exist before the data is imported. The import process does not implicitly create the SRS, but it does compare the coordinate system of the SRS with the coordinate system that is specified in the .prj file (if available with the shape file). The import process also verifies that the extents of the data in the shape file can be represented in the given spatial reference system. That is, the import process verifies that the extents lie within the minimum and maximum possible X, Y, Z, and M coordinates of the SRS.
The srs_name value is converted to uppercase unless you enclose it in double quotation marks.
The data type for this parameter is VARCHAR(128) or, if you enclose the value in double quotation marks, VARCHAR(130).
The table_schema value is converted to uppercase unless you enclose it in double quotation marks.
The data type for this parameter is VARCHAR(128) or, if you enclose the value in double quotation marks, VARCHAR(130).
The table_name value is converted to uppercase unless you enclose it in double quotation marks.
The data type for this parameter is VARCHAR(128) or, if you enclose the value in double quotation marks, VARCHAR(130).
If this parameter is specified, the number of names must match the number of columns that are imported from the dBASE file. If the table exists, the column definitions must match the incoming data. See Usage notes for an explanation of how attribute data types are mapped to DB2 data types.
The data type of this parameter is VARCHAR(32K).
The data type of this parameter is INTEGER.
IN tsName INDEX IN indexTsName LONG IN longTsName
The data type of this parameter is VARCHAR(32K).
For a new table, this parameter specifies the name of the new spatial column that is to be created. Otherwise, this parameter specifies the name of an existing spatial column in the table.
The spatial_column value is converted to uppercase unless you enclose it in double quotation marks.
The data type for this parameter is VARCHAR(128) or, if you enclose the value in double quotation marks, VARCHAR(130).
The type_schema value is converted to uppercase unless you enclose it in double quotation marks.
The data type for this parameter is VARCHAR(128) or, if you enclose the value in double quotation marks, VARCHAR(130).
If you are importing into a table that does not yet exist, this data type is also used for the data type of the spatial column. In that case, the data type can also be a super type of ST_Point, ST_MultiPoint, ST_MultiLineString, or ST_MultiPolygon.
The type_name value is converted to uppercase unless you enclose it in double quotation marks.
The data type for this parameter is VARCHAR(128) or, if you enclose the value in double quotation marks, VARCHAR(130).
Spatial records that exceed this size are stored separately in the LOB table space, which might be slower to access.
See the DB2 documentation about the CREATE TABLE SQL statement for a complete description of this value. See also the db2dart utility to determine the number of inline geometries for existing tables and the ability to alter the inline length.
The data type of this parameter is INTEGER.
Restriction: You cannot specify an id_column name that matches the name of any column in the dBASE file.
INTEGER NOT NULL PRIMARY KEY
If the value of the id_column_is_identity parameter
is not null and not 0 (zero), the definition is expanded as follows: INTEGER NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY
( START WITH 1 INCREMENT BY 1 )
The id_column value is converted to uppercase unless you enclose it in double quotation marks.
The data type for this parameter is VARCHAR(128) or, if you enclose the value in double quotation marks, VARCHAR(130).
The data type of this parameter is SMALLINT.
The data type of this parameter is INTEGER.
The data type of this parameter is INTEGER.
If you specify a value for the parameter and include the optional file extension, specify either .shp or .SHP. If the extension is null, an extension of .shp is appended.
The exception file holds the complete block of rows for which a single insert statement failed. For example, assume that one row cannot be imported because the shape data is incorrectly encoded. A single insert statement attempts to import 20 rows, including the one that is in error. Because of the problem with the single row, the entire block of 20 rows is written to the exception file.
Records are written to the exception file only when those records can be correctly identified, as is the case when the shape record type is not valid. Some types of corruption to the shape data (.shp files) and shape index (.shx files) do not allow the appropriate records to be identified. In this case, no records are written to the exception file, and an error message is issued to report the problem.
If you specify a value for this parameter, four files are created on the server machine. See Usage notes for an explanation these files. The stored procedure, which runs as a process that is owned by the DB2 instance owner, must have the necessary privileges on the server to create the files. If the files already exist, the stored procedure returns an error.
The data type of this parameter is VARCHAR(256).
The stored procedure, which runs as a process that is owned by the DB2 instance owner, must have the necessary privileges on the server to create the file. If the file already exists, the stored procedure returns an error.
The data type of this parameter is VARCHAR(256).
The data type of this output parameter is INTEGER.
The data type of this output parameter is VARCHAR(1024).
.dbf type | .dbf length1 | .dbf decimals 2 | SQL type | Comments |
---|---|---|---|---|
N | < 5 | 0 | SMALLINT | |
N | < 10 | 0 | INTEGER | |
N | < 20 | 0 | BIGINT | |
N | len | dec | DECIMAL(len,dec) | len<32 |
F | len | dec | REAL | len + dec < 7 |
F | len | dec | DOUBLE | |
C | len | CHAR(len) | ||
L | CHAR(1) | |||
D | DATE |
For example, assume that the dBASE file contains a column of data whose length (len) is defined as 20. Assume that the number of digits to the right of the decimal point (dec) is defined as 5. When DB2 Spatial Extender imports data from that column, it uses the values of len and dec to derive the following SQL data type: DECIMAL(20,5).
call DB2GSE.ST_IMPORT_SHAPE('/tmp/officesShape',NULL,'USA_SRS_1',NULL,
'OFFICES',NULL,0,NULL,'LOCATION',NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL,'/tmp/import_msg',?,?)
The two question marks at the end of this CALL command
represent the output parameters, msg_code and msg_text.
The values for these output parameters are displayed after the stored
procedure runs.