Search

SUBSTR



    This will be used to extract substrings.

     Syntax: substr (string, start_chr_count [, no_of_chars])

     Ex:
SQL> select substr('computer',2), substr('computer',2,5), substr('computer',3,7)
        from dual;
 

SUBSTR(  SUBST  SUBSTR
----------  -------   --------
omputer  omput   mputer

Ø  If no_of_chars parameter is negative then it will display nothing.
Ø  If both parameters except string are null or zeros then it will display nothing.
Ø  If no_of_chars parameter is greater than the length of the string then it ignores and calculates based on the orginal string length.
Ø  If start_chr_count is negative then it will extract the substring from right end.

1          2          3          4          5          6          7          8

C          O         M         P          U         T          E          R

                               -8 -7        -6        -5        -4        -3        -2        -1