我的PB程式資料庫升級程式

浪漫雙魚發表於2008-01-08

create or replace directory utllobdir as '/updates';
create table bfile_tab (bfile_column BFILE);
create table exe (blob_column BLOB);
create table dll (blob_column BLOB);
create table liveupdate(VER number);
----------------------------------------
declare
   a_blob  BLOB;
   a_bfile BFILE := BFILENAME('UTLLOBDIR','bus_mana.exe');
begin
   insert into bfile_tab values (a_bfile)
     returning bfile_column into a_bfile;
   insert into exe values (empty_blob())
     returning blob_column into a_blob;
   dbms_lob.fileopen(a_bfile);
   dbms_lob.loadfromfile(a_blob, a_bfile, dbms_lob.getlength(a_bfile));
   dbms_lob.fileclose(a_bfile);
   commit;
end;
/

---
declare
   a_blob  BLOB;
   a_bfile BFILE := BFILENAME('UTLLOBDIR','zs.dll');
begin
   insert into bfile_tab values (a_bfile)
     returning bfile_column into a_bfile;
   insert into dll values (empty_blob())
     returning blob_column into a_blob;
   dbms_lob.fileopen(a_bfile);
   dbms_lob.loadfromfile(a_blob, a_bfile, dbms_lob.getlength(a_bfile));
   dbms_lob.fileclose(a_bfile);
   commit;
end;
/
--------------
select dbms_lob.getlength(blob_column) from exe;
select dbms_lob.getlength(blob_column) from dll;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/11088128/viewspace-119097/,如需轉載,請註明出處,否則將追究法律責任。

相關文章