Document Type | Troubleshooting
Category | Administration
Applicable Product Version | 7FS02PS
Document Number | TADTS045
Issue
When executing a query file written with the SQL extension in the tbsql client using the @filename format, if the insert or select result contains Korean characters, the characters appear corrupted in the output.
1. Insert Attempt
vi test.sql
create table test (c1 varchar2(10));
INSERT INTO test VALUES ('๊ฐ');
INSERT INTO test VALUES ('๋');
INSERT INTO test VALUES ('๋ค');
INSERT INTO test VALUES ('๋ผ');
INSERT INTO test VALUES ('๋ง');
INSERT INTO test VALUES ('๋ฐ');
INSERT INTO test VALUES ('์ฌ');
INSERT INTO test VALUES ('์');
INSERT INTO test VALUES ('์');
INSERT INTO test VALUES ('์ฐจ');
INSERT INTO test VALUES ('์นด');
INSERT INTO test VALUES ('ํ');
INSERT INTO test VALUES ('ํ');
INSERT INTO test VALUES ('ํ');
commit;2. Result
SQL> @test Table 'TEST' created. 1 row inserted. TBR-23002: Missing single quote. at line 1, column 34 of null: TBR-23002: Missing single quote. at line 1, column 34 of null: TBR-23002: Missing single quote. at line 1, column 34 of null: TBR-23002: Missing single quote. at line 1, column 34 of null: TBR-23002: Missing single quote. at line 1, column 34 of null: TBR-23002: Missing single quote. at line 1, column 34 of null: TBR-23002: Missing single quote. at line 1, column 34 of null: TBR-23002: Missing single quote. at line 1, column 34 of null: TBR-23002: Missing single quote. at line 1, column 34 of null: TBR-23002: Missing single quote. at line 1, column 34 of null: 1 row inserted. TBR-23002: Missing single quote. at line 1, column 34 of null: TBR-23002: Missing single quote. at line 1, column 34 of null: Commit completed.
Cause
The cause of this issue is that the DB character set and the OS character encoding settings do not match. Because of this, tbsql cannot properly recognize or output Korean data, resulting in corrupted characters.
Solutions
- Create the test.sql file on your personal PC and save it with UTF8 encoding. Use tools like Notepad++ to verify the encoding.
- Copy the test.sql file from your personal PC to the DB server.
- Set the OS locale of the DB server to ko_KR.utf8.
- Set the encoding method of the remote access tool connecting to the DB server to UTF8. For example: in putty settings, Windows - Translation - Remote character set: UTF-8
- Add TB_NLS_LANG=UTF8 to the last line of the $TB_HOME/client/config/tbdsn.tbr file.
- Execute the script (@test.sql).
Example Execution
SQL> @test Table 'TEST' created. 1 row inserted. 1 row inserted. 1 row inserted. 1 row inserted. 1 row inserted. 1 row inserted. 1 row inserted. 1 row inserted. 1 row inserted. 1 row inserted. 1 row inserted. 1 row inserted. 1 row inserted. 1 row inserted. Commit completed. SQL> SELECT * FROM TEST; C1 ใ กใ ก ๊ฐ ๋ ๋ค ๋ผ ๋ง ๋ฐ ์ฌ ์ ์ ์ฐจ ์นด ํ ํ ํ 14 rows selected. SQL>