Quote:
|
Originally Posted by rajaryan4545
but the data in the source table has columns defined as NOT NULL and the data in those columns is inserted as blank spaces.
so when i am doing export using
db2se export_shape <db_name>
-fileName <file_name with complete path>
-selectStatement <statement selcting columns with alias names>
-messagesFile <msg_file with complete path>
the blank space are beeing exported as null values .instead of getting a blank space i am getting - (dash ie., null value i guess).i think db2 is thinking blankspaces as null values.
so when i am importing the exported data into target table (which is already created) i am getting the error as: EXPORTING NULL VALUES INTO NON NULL VALUES IS NOT ALLOWED.
and also when i am importing the exported data into a new table(which is not already present) it is importing the data into the table with the columns accepting NULLS.
|
I really can't follow you exactly where NULLs occur. The message you quote does not originate from the DB2 Spatial Extender; so you should explain the details for us.
Dbase files (.DBF) do not have the notion of NULL indicators for values. One can only set a '*' in the first field for a record to mark this record as being deleted.
NULLs are a serious problem because we somehow have to take care of the loss of information when moving data from DB2 to dBase files. During shape export, we store a value with all-blanks in the DBF file instead. To be consistent, we do the reverse upon shape import, i.e. if a value is blanks-only (or '\0's only), then we interpret this value as being a SQL NULL.
It would be possible to:
(a) check if the column is a string column, and if it is
(b) test whether the column is nullable, and if it is not
(c) insert the blanks-only in the DB2 table.
If you need something like that, you should open a PMR with IBM support.
Quote:
|
and also the datatypes of many columns are beeing changed unusual thing for me was the 'timestamp' column in the source has been changed to 'varchar' after importing to new table.
|
That has an easy answer: dBase files don't know "timestamps". So we can only export datetime values as strings. When you try to import such a file again, we see the string data type and, therefore, create a column of type VARCHAR in DB2. How else could we know that the values in the dBase file are timestamps?
Likewise, dBase files store numbers as text. So if we export an INTEGER, we have to account for 10 digits + sign = 11 characters. Again, when we import such a file with ST_shape_import (or db2se import_shape), we only see: numeric and 11 characters. We have no idea whether the 11th character is used for the sign and the 10th is blank, '0', '1', or '2' only. Therefore, we cannot guarantee that only values smaller than 2.14... billion occur, and we create a BIGINT column instead. We could scan over the whole dBase file - but that's a performance problem. To address such issues, you have to create the table first with the data type you want to have and then import into the existing table.
Quote:
|
1) so how should i retain the datatypes after importing with out changing.
|
Due to the insufficient information schema information in shapfiles, you will have to take care of this manually, i.e. use db2look or some other mechanism to extract the table definition, then create the target table yourself and import into an existing table.
Quote:
|
2) and how should i overcome the null values instead of blank spaces.
|
As stated above, you can either open a PMR or work around this issue. To work around it, you could add a BEFORE INSERT trigger for your table that changes a NULL to a blanks-only string.
Also, blanks-only is really strange. It may be a good idea to revisit your data model and figure out if NULLs aren't a much better choice.
p.s: If you open a PMR, you should have a strong case to support your requirement to insert blanks-only as strings. If I recall correctly, I read somewhere when I implemented this that blanks-only indicate the absence of a value in dBase.