Transformar imagem (Long Raw p/ Blob)

Dúvidas, dicas e truques de SQL, Select, Update, Delete, cláusulas, operações com joins, Funções em SQLs, etc
Alessandro
Rank: Programador Júnior
Rank: Programador Júnior
Mensagens: 23
Registrado em: Seg, 05 Jul 2004 4:29 pm

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.
Avatar do usuário
tfg
Rank: Analista Júnior
Rank: Analista Júnior
Mensagens: 83
Registrado em: Seg, 03 Mai 2004 3:38 pm
Localização: Novo Hamburgo - RS

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. 
Responder
  • Informação
  • Quem está online

    Usuários navegando neste fórum: Nenhum usuário registrado e 18 visitantes