[gdal-dev] ORA-01406 error when reading many attributes from Oracle

Jukka Rahkonen jukka.rahkonen at mmmtike.fi
Wed Oct 17 03:35:51 PDT 2012


Jukka Rahkonen <jukka.rahkonen <at> mmmtike.fi> writes:


> I suspect that the reason for the trouble is that this field is a
> 17 character wide VARCHAR2 and I have in the data values like
> "ÖVRE SÖDERGÄRDAN ". Database is using UTF-8 and Ö,Ö and Ä are
> taking more than one byte each. Perhaps OCI driver develops come
> from some ASCII country and did not bother to think about Oracle's
> character and byte semantics throughly. It seems somehow fuzzy for
> me even after reading this article
> http://myorastuff.blogspot.fi/2009/02/character-and-byte-
> semantics-in-oracle.html

I can repeat the error with a minimal one-row test table having a field
NAME VARCHAR2(6)
and value ÄäÖöÅå

VARCHAR2(6) means the same as VARCHAR2(6 CHAR) but OGR OCI driver thinks 
that it means the same as VARCHAR2(6 BYTE) and that leads to ORA-01406 
error if the character string has more that 6 bytes even it has 6 or less
characters. I will make a ticket about this.

Now, can anybody suggest a handy workaround? I can take the IDs and names
out into a text file and join names with the rest of the data with 
Spatialite or some other tool but I have 14 layers to process, 1.1 million 
rows on each and that would probably be too slow. I do not have rights to 
add a new attribute NAME2 VARCHAR(40 BYTE) into Oracle but perhaps I will 
need to ask DB admin to create that for me.

-Jukka-




More information about the gdal-dev mailing list