Browse » Home
Tuesday, May 21, 2013
How to Use Control Characters With Oracle SQL
Find Decimal Value
1. Open the ASCII table. Here you will find the comprehensive list of decimal values for each control character at http://ascii-table.com/ascii.php.
2. Find the decimal value of the desired control character from the ASCII table.
3. Input that decimal value of the control character into the CHR function. This will make Oracle print the control character in Oracle SQL*Plus, as well as in PL/SQL.
Example 1
4. Open the ASCII table. You will find the comprehensive list of decimal values for each control character at http://ascii-table.com/ascii.php.
5. Find the decimal value for the control character corresponding with Line Feed (^J). Looking at the table, you'll see that the corresponding decimal value is 10.
6. Input integer value 10 into the CHR function. The following SQL will print a line feed between the two strings in sqlplusSQL> select 'test'||chr(10)||'abc' from dual;'TEST'||--------testabc
Example 2
7. Open the ASCII table. You will find the comprehensive list of decimal values for each control character at http://ascii-table.com/ascii.php.
8. Find the decimal value for the control character corresponding with Backspace (^H). Looking at the table, you'll see that the corresponding decimal value is 8.
9. Input 8 into the CHR function. The following SQL will print a backspace after printing the first string, wiping out the last character of the first string, before printing the second.SQL> select 'test'||chr(8)||'abc' from dual;'TEST'||--------tesabc
Example 3
10. Open the ASCII table. You will find the comprehensive list of decimal values for each control character at http://ascii-table.com/ascii.php.
11. Find the decimal value for the control character corresponding with Horizontal Tabulation (^t). Looking at the table, you'll see that the corresponding decimal value is 9.
12. Input 9 into the CHR function. The following SQL will print a horizontal tab after printing the first string, before printing the second string.SQL> select 'test'||chr(9)||'abc' from dual;'TEST'||--------test abc