Introduction

These functions are opposites.

CHR(code) returns a character from the current character set identified by its binary equivalent.

ASCII(character) returns the binary equivalent of the character passed into the function.

Demo

SQL>
SQL> declare--  w  w  w .ja v a  2 s  .  c  o  m
  2      v_nr number;
  3      v_tx char(1);
  4  begin
  5      v_nr:=ascii('A');
  6      DBMS_OUTPUT.put_line(v_nr);
  7      v_tx:=chr(v_nr);
  8      DBMS_OUTPUT.put_line(v_tx);
  9  end;
 10  /
65
A

PL/SQL procedure successfully completed.
SQL>

Useful character specifications are

  • CHR(10): Line feed
  • CHR(13): Carriage return
  • CHR(9): Tab

CHR(10) and CHR(13) usually implement the "next line" command.

In some cases, just CHR(10) is enough.

CHR(9) uses the default tab spacing of the current text environment.

Demo

SQL>
SQL> begin-- ww w .  j a  v  a2  s  .  c  om
  2      DBMS_OUTPUT.put_line('Line#1'||
  3                  chr(10) ||chr(9) ||'Line#2');
  4  end;
  5  /
Line#1
        Line#2

PL/SQL procedure successfully completed.

SQL>

Related Topic