This chapter shows how to convert a database to locale UTF8.

1 Export database

The first step is to export the database stablising the environment variables to the corresponding database current locale.

export DB_LOCALE=es_es.8859-1 (or es_es.8859-15)
export CLIENT_LOCALE=es_es.8859-1 (or es_es.8859-15)

Export the database.

dbexport database_name -ss

2 Import database

To import the database set the environment variable CLIENT_LOCALE to the current locale and DB_LOCALE to UTF8.

export DB_LOCALE=en_us.UTF8
export CLIENT_LOCALE=es_es.8859-1 (or es_es.8859-15)

Then import the database using the dbexport previously generated.

dbimport database_name in d_dbspace_name

3 Convert clobs to UTF8

Finally it is necessary to execute this XSQL-Script to convert the content in CLOB fields. This script can be execute from command line or DBStudio tool.

XSQL-Script clob2utf8

This script must be execute only one time. If you execute this script more than one time the content of columns will be corrupted.

        <!-- WARNING: foreach clob raw read -->
        <system.setProperty name='xsqlscript.clob.raw' value='true' />
            <in prefix='m_'>
                    <null />
                    <null />
                    <null />
                    <null />
                        <println><m_table_name />.<m_column_name /> <m_data_type/></println>

                        <connection.begin />
                            <select prefix='m_' for-update='yes'>
                                #m_column_name text
                                <from table='#m_table_name' />
                                <update table='#m_table_name'>
                                    <column name='#m_column_name'>
                                    <m_text />
                                    <where-current-of />
                        <connection.commit />