Add load_blob test procedure
This commit is contained in:
parent
830a5e22d8
commit
58ea0916bd
@ -9,7 +9,7 @@ create domain D_ID as BIGINT;
|
|||||||
create domain D_BIGINT as BIGINT;
|
create domain D_BIGINT as BIGINT;
|
||||||
|
|
||||||
create table test_div(
|
create table test_div(
|
||||||
test_div_id d_id generated always as identity
|
test_div_id D_ID generated always as identity
|
||||||
, numerator D_BIGINT
|
, numerator D_BIGINT
|
||||||
, denominator D_BIGINT
|
, denominator D_BIGINT
|
||||||
, result COMPUTED BY ( DIV(numerator, denominator) )
|
, result COMPUTED BY ( DIV(numerator, denominator) )
|
||||||
@ -31,19 +31,21 @@ create domain D_STATUS as CHAR(1) default 'U' not null check (VALUE IN ('U', 'F'
|
|||||||
comment on domain D_STATUS is 'unset, failed, loaded, written';
|
comment on domain D_STATUS is 'unset, failed, loaded, written';
|
||||||
|
|
||||||
create table test_blobs(
|
create table test_blobs(
|
||||||
test_blobs_id d_id generated always as identity
|
test_blobs_id D_ID generated always as identity
|
||||||
, description D_DESCRIPTION
|
, description D_DESCRIPTION
|
||||||
, file_type D_FILETYPE
|
, file_type D_FILETYPE
|
||||||
, source_file D_PATH
|
, source_file D_PATH
|
||||||
, source_status D_STATUS
|
, source_status D_STATUS
|
||||||
|
, source_bytes D_BIGINT
|
||||||
, target_file D_PATH
|
, target_file D_PATH
|
||||||
, target_status D_STATUS
|
, target_status D_STATUS
|
||||||
|
, target_bytes D_BIGINT
|
||||||
, the_blob D_BLOB
|
, the_blob D_BLOB
|
||||||
, constraint pk_test_blobs_id primary key (test_blobs_id) using index idx_test_blobs_id
|
, constraint pk_test_blobs_id primary key (test_blobs_id) using index idx_test_blobs_id
|
||||||
);
|
);
|
||||||
|
|
||||||
set term ^;
|
set term ^;
|
||||||
create trigger t_iub_test_blobs for test_blobs before insert or update
|
create or alter trigger t_iub_test_blobs for test_blobs before insert or update
|
||||||
as begin
|
as begin
|
||||||
|
|
||||||
new.file_type = upper(new.file_type);
|
new.file_type = upper(new.file_type);
|
||||||
@ -51,8 +53,35 @@ as begin
|
|||||||
new.target_status = upper(new.target_status);
|
new.target_status = upper(new.target_status);
|
||||||
|
|
||||||
end ^
|
end ^
|
||||||
|
set term ;^
|
||||||
|
|
||||||
|
|
||||||
|
set term ^;
|
||||||
|
create or alter procedure load_blob ( a_test_blob_id D_ID ) sql security definer
|
||||||
|
as
|
||||||
|
declare asource_file D_PATH;
|
||||||
|
declare ablob D_BLOB;
|
||||||
|
declare result D_BIGINT;
|
||||||
|
declare status D_STATUS;
|
||||||
|
begin
|
||||||
|
|
||||||
|
select source_file, the_blob from test_blobs where test_blobs_id = :a_test_blob_id into asource_file, ablob;
|
||||||
|
select LoadBlobFromFile( :asource_file, :ablob ) from rdb$database into :result;
|
||||||
|
if (result > 0 ) then
|
||||||
|
status = 'L';
|
||||||
|
else if ( result < 0 ) then
|
||||||
|
status = 'F';
|
||||||
|
|
||||||
|
|
||||||
|
update test_blobs
|
||||||
|
set the_blob = :ablob
|
||||||
|
, source_bytes = :result
|
||||||
|
, source_status = :status
|
||||||
|
where test_blobs_id = :a_test_blob_id;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
end ^
|
||||||
|
|
||||||
set term ;^
|
set term ;^
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user