Oracle PL/SQL Tutorial/PL SQL Data Types/Unicode

Материал из SQL эксперт
Перейти к: навигация, поиск

Find the location of "\0303" using INSTRC

   <source lang="sql">

SQL> SQL> DECLARE

 2     --The underlying database datatype for this example is Unicode UTF-16
 3     x NCHAR(40) := UNISTR("The character a\0303 could be composed.");
 4  BEGIN
 5
 6     DBMS_OUTPUT.PUT_LINE(INSTRC(x,UNISTR("\0303")));
 7
 8     --Find the location of "\0303" using INSTR4
 9     DBMS_OUTPUT.PUT_LINE(INSTR4(x,UNISTR("\0303")));
10  END;
11  /

PL/SQL procedure successfully completed.</source>


INSTR2(x, UNISTR("\D834"))

   <source lang="sql">

SQL> SQL> DECLARE

 2    x NCHAR(40) := UNISTR("This is a \D834\DD1E test");
 3  BEGIN
 4    DBMS_OUTPUT.PUT_LINE (INSTR2(x, UNISTR("\D834")));
 5    DBMS_OUTPUT.PUT_LINE (INSTR4(x, UNISTR("\D834")));
 6  END;
 7  /

PL/SQL procedure successfully completed. SQL> SQL></source>


The underlying database datatype for this example is Unicode UTF-8

   <source lang="sql">

SQL> DECLARE

 2
 3     x CHAR(30 CHAR) := "The character ?is two-bytes.";
 4  BEGIN
 5     --Find the location of "is" in terms of characters
 6     DBMS_OUTPUT.PUT_LINE(INSTR(x,"is"));
 7
 8     --Find the location of "is" in terms of bytes
 9     DBMS_OUTPUT.PUT_LINE(INSTRB(x,"is"));
10  END;
11  /

PL/SQL procedure successfully completed. SQL> SQL> SQL></source>