Oracle PL/SQL Tutorial/System Packages/utl raw — различия между версиями

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

Версия 13:45, 26 мая 2010

Difference between utl_raw.length and length

SQL>
SQL> create table t ( r raw(10) );
Table created.
SQL>
SQL>
SQL> insert into t values ( utl_raw.cast_to_raw("helloWorld" ) );
1 row created.
SQL>
SQL> select utl_raw.length(r), length(r)/2 from t;
UTL_RAW.LENGTH(R) LENGTH(R)/2
----------------- -----------
               10          10
SQL>
SQL>
SQL> drop table t;
Table dropped.
SQL>


select utl_raw.cast_to_varchar2(hextoraw("534d495448")) from dual

SQL>
SQL>
SQL> select utl_raw.cast_to_varchar2(hextoraw("534d495448")) from dual;
UTL_RAW.CAST_TO_VARCHAR2(HEXTORAW("534D495448"))
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SMITH
SQL>


select utl_raw.cast_to_varchar2(hextoraw("787878")) from dual

SQL>
SQL>
SQL> select utl_raw.cast_to_varchar2(hextoraw("787878")) from dual;
UTL_RAW.CAST_TO_VARCHAR2(HEXTORAW("787878"))
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
xxx
SQL>


Use utl_raw.cast_to_raw to convert string to raw

SQL>
SQL>
SQL> select utl_raw.cast_to_raw( "Hello World!" ) data
  2    from dual;
DATA
--------------------------------------------------------------------------------
48656C6C6F20576F726C6421
SQL>


Use utl_raw.substr

SQL>
SQL> create table t ( r raw(10) );
Table created.
SQL>
SQL> insert into t values ( utl_raw.cast_to_raw("helloWorld" ) );
1 row created.
SQL>
SQL> select utl_raw.substr(r,2,3) r1, hextoraw(substr(r,3,6)) r2 from t
  2
SQL> drop table t;
Table dropped.
SQL>


utl_raw.cast_to_raw

SQL>
SQL> create table demo
  2  ( id           int primary key,
  3    theBlob      blob
  4  )
  5  /
Table created.
SQL> update demo set theBlob = utl_raw.cast_to_raw("Hello World") where id = 1
  2  /
0 rows updated.
SQL> drop table demo;
Table dropped.