Página 1 de 1
Transformar imagem (Long Raw p/ Blob)
Enviado: Qua, 22 Set 2004 11:21 am
por Alessandro
Bom dia.
Existe algum script p/ transforma uma imagem Long Raw p/ Blob, ou seja, tenho em uma mesma tabela uma campo foto que é Long Raw e outro campo fotob que é Blob. Preciso copiar a imagem Long Raw p/ o campo Blob.
Muito Obrigado.
Enviado: Sex, 11 Mar 2005 5:50 pm
por tfg
Sim, pode usar o TO_LOB... (da mesma forma que o TO_DATE, TO_CHAR, etc)
Veja um exemplo do Tom Kyte:
http://asktom.oracle.com/pls/asktom/f?p ... 3885403654
Selecionar tudo
ops$tkyte@ORA817DEV> create table gtt ( id int, x blob );
Table created.
ops$tkyte@ORA817DEV>
ops$tkyte@ORA817DEV> create table t ( id int primary key, x long raw );
Table created.
ops$tkyte@ORA817DEV>
ops$tkyte@ORA817DEV> insert into t values( 1, rpad( 'a', 2000, 'a' ) );
1 row created.
ops$tkyte@ORA817DEV>
ops$tkyte@ORA817DEV>
ops$tkyte@ORA817DEV> declare
2 l_id number := 1;
3 l_blob blob;
4 begin
5 execute immediate '
6 insert into gtt
7 select :x, to_lob(x)
8 from t
9 where id = :x' using l_id, l_id;
10
11 select x into l_blob from gtt where id = l_id;
12 end;
13 /
PL/SQL procedure successfully completed.
if you just want to convert single row for a session. use
create table new_table as select ...., to_lob(long_raw) from old_table
to permanently convert all rows.