ASA SQL Reference
SQL Functions
Alphabetical list of functions
Converts strings between character sets.
CSCONVERT (
string-expression,
'target-charset'
[ , 'source-charset' ] )
string-expression The string.
target-charset The destination character set. Target-charset can be one of the following:
os_charset The character set used by the operating system.
db_charset The character set used by the database.
any other supported character set label You can specify any of the Adaptive Server Anywhere supported character set labels. For more information, see Character set labels.
source-charset The character set used by the original string-expression. The default is db_charset. Source-charset-name can be one of the following:
os_charset The character set used by the operating system.
db_charset The character set used by the database.
any other supported character set label You can specify any of the Adaptive Server Anywhere supported character set labels. For more information, see Character set labels.
SQL/92 SQL/92 compatible.
SQL/99 Vendor extension.
Sybase Compatible with Adaptive Server Enterprise.
Starting a database server using character set translation
This fragment converts the mytext column from the Traditional Chinese character set to the Simplified Chinese character set:
SELECT CSCONVERT (mytext, 'cp936', 'cp950') FROM mytable
This fragment converts the mytext column from the database character set to the Simplified Chinese character set:
SELECT CSCONVERT (mytext, 'cp936') FROM mytable
If a filename is stored in the database, it is stored in the database's character set. If the server is going to read from or write to a file whose name is stored in a database (for example, in an external stored procedure), the filename must be explicitly converted to the operating system's character set before the file can be accessed. Filenames stored in the database and retrieved by the client are converted automatically to the client's character set, so explicit conversion is not necessary.
This fragment converts the filename column from the database character set to the operating system character set:
SELECT CSCONVERT (filename, 'os_charset') FROM mytable
A table contains a list of filenames. An external stored procedure takes a filename from this table as a parameter and reads information directly out of that file. The following statement works when character set conversion is not required:
SELECT MYFUNC( filename ) FROM mytable
where mytable is a table that contains a filename column. However, if you need to convert the filename to the character set of the operating system, you would use the following statement.
SELECT MYFUNC( csconvert( filename, 'os_charset' ) ) FROM mytable