I have table with columns id(number), photo(blob) and thumbnail(blob) . I
would like to insert image (using stored procedure) from file to column
photo and in same time copy reduced image to column thumbnail. My code is:
CREATE OR REPLACE PROCEDURE "MDEMO"."PUT_PH OTO_THUMB"
(
image_file_dire ctory in varchar2,
image_file_name in varchar2,
image_file_mime _type in varchar2,
image_http_path in varchar2,
image_http_name in varchar2,
ord_procedure_p ath in varchar2,
ord_content_typ e in varchar2,
ord_content_blo b out blob
)
as
localImage ordsys.ordimage ;
localThumb ordsys.ordimage ;
begin
/*
* Create an empty object.
*/
localImage := ordsys.ordimage ( ordsys.ordsourc e( empty_blob(),
null,
null,
null,
null,
null ),
null,
null,
null,
null,
null,
null,
null );
localThumb := ordsys.ordimage ( ordsys.ordsourc e( empty_blob(),
null,
null,
null,
null,
null ),
null,
null,
null,
null,
null,
null,
null );
/*
* Process the request based on the location of the new image.
*/
if length( image_file_dire ctory ) 0 then
/*
* Image is stored as a FILE in a database server directory.
* Set the local image object to reference the specified file.
*/
localImage.clea rLocal();
localImage.setS ource( 'FILE',
image_file_dire ctory,
image_file_name );
localImage.setM imeType( image_file_mime _type );
elsif length ( image_http_path ) 0 then
/*
* Image is stored on a web server somewhere.
* Set the local image object to reference the URL.
*/
localImage.clea rLocal();
localImage.setS ource( 'HTTP',
image_http_path ,
image_http_name );
else
/*
* Image is being uploaded from the client to be stored in the
database.
* Set the flag to indicate the image is to be stored in the object's
* local-data BLOB.
*/
localImage.setL ocal();
localImage.setM imeType( ord_content_typ e );
localThumb.setM imeType( ord_content_typ e );
/* copy reduced image from localImage to localThumb*/
localImage.proc essCopy('maxSca le=50,50',local Thumb);
end if;
/*
* Update the image object in the table. If the image is to be stored in
* the object's local-data BLOB, then return the LOB handle so the web
* agent can store the image in the database.
*/
if localImage.isLo cal() then
update MPHOTOS i set i.IMAGE = localImage where ID =
ord_procedure_p ath
return i.IMAGE.source. localdata into ord_content_blo b;
update MPHOTOS i set i.THUMB = localThumb where ID =
ord_procedure_p ath
return i.THUMB.source. localdata into ord_content_blo b;
else
update MPHOTOS i set i.IMAGE = localImage where ID =
ord_procedure_p ath;
update MPHOTOS i set i.THUMB = localThumb where ID =
ord_procedure_p ath;
end if;
end;
/
SHOW ERRORS;
When I want to execute (using intermedia clipboard) I receive a message
"invalid LOB locator specified". What is wrong?
Thanx in advance
--
--
,-._|\ Vladimir Kanovnik Melbourne PC UsersGroup
/ Oz \ Email: vlad@melbpc.org .au
\_,--.x/ Phone: +61 3 9791 1409
v Fax: +61 3 9791 1946
Mobile: +61 412 134012
~~ Australia ~~
would like to insert image (using stored procedure) from file to column
photo and in same time copy reduced image to column thumbnail. My code is:
CREATE OR REPLACE PROCEDURE "MDEMO"."PUT_PH OTO_THUMB"
(
image_file_dire ctory in varchar2,
image_file_name in varchar2,
image_file_mime _type in varchar2,
image_http_path in varchar2,
image_http_name in varchar2,
ord_procedure_p ath in varchar2,
ord_content_typ e in varchar2,
ord_content_blo b out blob
)
as
localImage ordsys.ordimage ;
localThumb ordsys.ordimage ;
begin
/*
* Create an empty object.
*/
localImage := ordsys.ordimage ( ordsys.ordsourc e( empty_blob(),
null,
null,
null,
null,
null ),
null,
null,
null,
null,
null,
null,
null );
localThumb := ordsys.ordimage ( ordsys.ordsourc e( empty_blob(),
null,
null,
null,
null,
null ),
null,
null,
null,
null,
null,
null,
null );
/*
* Process the request based on the location of the new image.
*/
if length( image_file_dire ctory ) 0 then
/*
* Image is stored as a FILE in a database server directory.
* Set the local image object to reference the specified file.
*/
localImage.clea rLocal();
localImage.setS ource( 'FILE',
image_file_dire ctory,
image_file_name );
localImage.setM imeType( image_file_mime _type );
elsif length ( image_http_path ) 0 then
/*
* Image is stored on a web server somewhere.
* Set the local image object to reference the URL.
*/
localImage.clea rLocal();
localImage.setS ource( 'HTTP',
image_http_path ,
image_http_name );
else
/*
* Image is being uploaded from the client to be stored in the
database.
* Set the flag to indicate the image is to be stored in the object's
* local-data BLOB.
*/
localImage.setL ocal();
localImage.setM imeType( ord_content_typ e );
localThumb.setM imeType( ord_content_typ e );
/* copy reduced image from localImage to localThumb*/
localImage.proc essCopy('maxSca le=50,50',local Thumb);
end if;
/*
* Update the image object in the table. If the image is to be stored in
* the object's local-data BLOB, then return the LOB handle so the web
* agent can store the image in the database.
*/
if localImage.isLo cal() then
update MPHOTOS i set i.IMAGE = localImage where ID =
ord_procedure_p ath
return i.IMAGE.source. localdata into ord_content_blo b;
update MPHOTOS i set i.THUMB = localThumb where ID =
ord_procedure_p ath
return i.THUMB.source. localdata into ord_content_blo b;
else
update MPHOTOS i set i.IMAGE = localImage where ID =
ord_procedure_p ath;
update MPHOTOS i set i.THUMB = localThumb where ID =
ord_procedure_p ath;
end if;
end;
/
SHOW ERRORS;
When I want to execute (using intermedia clipboard) I receive a message
"invalid LOB locator specified". What is wrong?
Thanx in advance
--
--
,-._|\ Vladimir Kanovnik Melbourne PC UsersGroup
/ Oz \ Email: vlad@melbpc.org .au
\_,--.x/ Phone: +61 3 9791 1409
v Fax: +61 3 9791 1946
Mobile: +61 412 134012
~~ Australia ~~