Ordimage to BLOB
Hi,
I've seen numerous threads about copying BLOB's to ORDimage, but none about doing it in reverse.
The thing is that we already have a blob table in production, and want to start using ORDimage for initial insertion but keep the existing code unchanged for now.
This is what I have tried, it doesnt seem to work, results in a null BLOB.
Declaration
image1 ORDSYS.ORDIMAGE;
image2 ORDSYS.ORDIMAGE;
b_pic1 blob;
b_pic2 blob;
/* code snippet to work the image1 and image2. Those images come out fine */
insert into blobtable (id, pic1, pic2) values (seq.nextval, empty_blob(),empty_blob())
return pic1,pic2 into b_pic1,b_pic2;
b_pic1 := image1.source.localdata;
b_pic2 := image2.source.localdata;
Any help appreciated.
Regards
Oli
Found it out.
I have to use :
ORDSYS.ORDImage.processCopy(new_image.source.localdata,
'fileFormat='||image1.getfileformat, b_pic1);
ORDSYS.ORDImage.processCopy(new_thumb.source.localdata,
'fileFormat='||image2.getfileformat, b_pic2);
instead of the
b_pic1 := image1.source.localdata;
b_pic2 := image2.source.localdata;
Regards
Oli
Similar Messages
-
ORDSYS.ORDimage and BLOB convertion
Hi every one,
I have a ORDSYS.ORDimage in a table (under Oracle 9i) that I need to show in a Forms 6i Image item (wich is finally a BLOB I guess).
Is there anyone that could tell me how to convert ORDSYS.ORDimage into a BLOB. I found in the interMedia documentation examples on how to save a BLOB into a ORDSYS.ORDimage with the filename of the image but I found nothing on converting ORDSYS.ORDimage into BLOB and vice versa.
Thank everyone for your help.
MarcAnd you are possible to display blob from table in form s image item?
I tried this, but it didn't go, can you tell me, how did you do? -
ORDSYS.ORDIMAGE to BLOB data type in select ??
Is posible to make a SELECT that return a BLOB field from a ORDIMAGE field..??
Example: I have the table XXX :
CREATE TABLE XXX(
image ORDSYS.ORDIMAGE
Now.. I need return the "image" field but like a BLOB field..
It's possible ... ??http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:56973810055298
-
ORDSYS.ORDIMAGE vs BLOB
Dear all,
I've designed a table with an ordsys.ordimage field for images. BIG MISTAKE, because there is no possibility to upload images from a form. I'd like to change it into a BLOB field but an error arises:
"You cannot modify the column definition for types CLOB, NCLOB, BFILE, BLOBand Intermedia Object types(ORDSYS.ORDIMAGE, ORDSYS.ORDAUDIO, ORDSYS.ORDVIDEO). (WWV-17079)"
Could I change it anyhow in order not to build a new table? I have a lot of forms referring to that table and I should change these forms too....(and we know it is pretty difficult)...
I would appreciate any help.
TomasAnd you are possible to display blob from table in form s image item?
I tried this, but it didn't go, can you tell me, how did you do? -
Hi,
Is it possible to create an ORDSYS.ORDImage object out of a BLOB?
I would like to retrieve image's height and width and I know that ordimage object has methods I need, but I store images as file attributes of an item. When displaying the attributes' values I retrieve data from proper tables using PL/SQL procedure. However, files are stored in WWV_DOCUMENTS where obviously there is no information about the height or width of an image and the image is displayed in its actual size, which is what I would like to change. How can I achieve it?
Thanks,
EwaIf you have your images stored in a blob, you can use the intermedia relational interface to process the images, see:
http://otn.oracle.com/doc/oracle8i_816/inter.816/relational_interface/mm_relat.htm#1086668
You will get results in XML and can store the attributes as XML or us the PL/SQL XML parser to get the values. -
Hi
I need to extract the BLOB from an ORDImage object and store it in the same table (for use in an APEX report).
I've managed to accomplish this but can't understand why another simpler (to me anyway) approach fails.
CREATE TABLE ORDImage_images
(image_id NUMBER PRIMARY KEY,
filename VARCHAR2(20),
image ORDSYS.ORDImage,
thumbnail ORDSYS.ORDIMAGE,
blob_thumb BLOB);
-- load the image and confirm the image is loaded and thumbnail and blob_thumb columns are null
-- try to extract the BLOB
DECLARE
l_image_id INTEGER:= 1;
l_orig ORDSYS.ORDImage;
l_thumb ORDSYS.ORDImage;
BEGIN
-- lock row
SELECT image
INTO l_orig
FROM ORDImage_images
WHERE image_id = l_image_id FOR UPDATE;
-- clear thumbnail and blob_thumb columns just in case
UPDATE ORDImage_images
SET thumbnail = null, blob_thumb = null
WHERE image_id = l_image_id;
-- this doesn't work
l_thumb := ORDSYS.ORDImage.Init();
-- but this does
UPDATE ORDImage_images
SET thumbnail = ORDSYS.ORDImage.Init()
WHERE image_id = l_image_id;
SELECT thumbnail
INTO l_thumb
FROM ORDImage_images
WHERE image_id = l_image_id;
l_orig.processCopy('maxScale=128 128',l_thumb);
UPDATE ORDImage_images
SET blob_thumb = l_thumb.source.localdata
WHERE image_id = l_image_id;
COMMIT;
END;I get the following error:
ORA-29400: data cartridge error
IMG-00710: unable to write to destination image
ORA-22275: invalid LOB locator specified
ORA-06512: at "ORDSYS.ORDIMG_PKG", line 1074
ORA-06512: at "ORDSYS.ORDIMAGE", line 175
ORA-06512: at line 32
29400. 00000 - "data cartridge error\n%s"
*Cause: An error has occurred in a data cartridge external procedure.
This message will be followed by a second message giving
more details about the data cartridge error.
*Action: See the data cartridge documentation
for an explanation of the second error message.I can't see why I need to use the thumbnail column (which I don't have any other use for) to initialise the l_thumb local variable. Why doesn't
l_thumb := ORDSYS.ORDImage.Init();accomplish the same thing? Or am I missing something really obvious?
Thanks for any help
Brian
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - ProductionORDSYS.ORDImage.Init() initializes the image object and provides a LOB locator to the BLOB field of the object.
When a LOB that is being initialized is a persistent LOB (a column in the table), the LOB locator points to a location where LOB content can be written to. So processCopy can write to the BLOB. This is what happens in your example that works.
When a LOB that is being initialized is not persistent (for example, is a variable in a PL/SQL program), then the LOB locator is not pointing to any location. A temporary LOB has to be created for this LOB locator.
For example,
l_thumb := ORDSYS.ORDImage.Init();
dbms_lob.createTemporary(l_thumb.source.localData, true);
-- processCopy
-- don't forget to free the space when done
dbms_lob.freeTemporary(l_thumb.source.localData);
Now you would not have to create a column just to be a destination for the processCopy.
You could also directly processCopy to the destination BLOB (blob_thumb in your example), using the relational interface for processCopy. This will avoid a copy from the local variable to the destination BLOB, and the overhead of creating and deleting the temporary lob.
blob_thumb := empty_blob(); -- to get the LOB locator
processCopy(l_orig.source.localData, 'maxscale=128x128',blob_thumb);
-- see http://docs.oracle.com/cd/E11882_01/appdev.112/e10776/ch_relatref.htm#g1116554 (processCopy for BLOBs) for details.
Finally, if you want to keep the thumbnail image in ORDImage and still use APEX, you could do that - specify to APEX the location of the BLOB in the ORDImage object (by referring to thumbnail.source.localData). Then you could work with image and thumbnail columns in your table, initialize both with ORDSYS.ORDImage.init(), and use processCopy for ORDImage objects.
Edited by: mannamal on Oct 17, 2012 2:32 PM -
How to show an ORDImage thumbnail without storing it ?
Hi,
I'm using Oracle 10g r2.
I need to show ORDImages (and BLOBs).
Here is my procedure that shows thumbnails :
create or replace procedure show_photo_thumbnail(v_id_photo in number, v_height in number, v_width in number) as
obj ordsys.ordimage;
obj2 ordsys.ordimage;
begin
--obj2 := ordsys.ordimage.init();
select phot_source into obj from photos where phot_id = v_id_photo;
select phot_source into obj2 from photos where phot_id = v_id_photo for update;
obj.processcopy('maxscale= '||v_width||' '||v_height, obj2);
owa_util.mime_header(nvl(obj2.getmimetype(),'application/octet'), false );
htp.p('content-length: ' || obj2.getcontentlength());
htp.p('content-disposition: filename="' || obj2.source.srcname || '"');
owa_util.http_header_close;
wpg_docload.download_file(obj2.source.localdata);
commit;
end;It works, but if I call this function repeatedly (from our apex application), the image quality becomes less and less good, it seems it processes always the same image.
And for example if I call show_photo_thumbnail(1126, 150, 150) and then show_photo_thumbnail(1126, 500, 500), it seems the 500 x 500 image is processed from the 150 x 150 thumbnail so the quality is very poor.
I read the entire documentation and I really don't understand why.
By calling this other procedure we can see that the content stored stay unchanged :
procedure show_photo_infos(v_id_photo in number, v_height in number, v_width in number) as
obj ordsys.ordimage;
obj2 ordsys.ordimage;
begin
select phot_source into obj from photos where phot_id = v_id_photo;
select phot_source into obj2 from photos where phot_id = v_id_photo for update;
obj.processcopy('maxscale= '||v_width||' '||v_height, obj2);
dbms_output.put_line('obj : '||obj.getmimetype()||', '||obj.getcontentlength()||' bytes, '||obj.getwidth()||' x '||obj.getheight());
dbms_output.put_line('obj2 : '||obj2.getmimetype()||', '||obj2.getcontentlength()||' bytes, '||obj2.getwidth()||' x '||obj2.getHeight());
end;
show_photo_infos(1126, 200, 200);
obj : image/jpeg, 79754 bytes, 572 x 504
obj2 : image/jpeg, 4635 bytes, 200 x 176Any help would be much appreciated.
Thanks.
Yann.It should work exactly the same for ORDimage and BLOBs, as ORDImage stores and updates the image content in a BLOB attribute.
The difference you are seeing might be because of which object you are reading. In the first example, obj2 was selected for update, but obj1 was not. So the local variable obj1 had the old data which was printed out, and this was different from the data in obj2, which had the changes that were updated in the table.
If you don't want to persist the updated image, then you can select for update, make changes as you are currently, but then rollback at the very end (after you download the content). Then the original image will be retained in the table and changes you made in this transaction will be discarded. The next time you run the procedure you will be operating on the original image.
I also notice you have a commit in the very first code snippet but not later. Depending on your logging settings that might be having an impact as well. -
Problem with reading ORDImage from DB
I have table imgtable with
id number
Image ordsys.ordImage
columns and for query
declare
src BLOB;
BEGIN
Select t.image.getcontent into src from imgtable t where t.id = 1;
END;
I receive following erros:
Select t.image.getcontent into src from imgtable t where t.id = 1;
ERROR at line 4:
ORA-06550: line 4, column 12:
PL/SQL: ORA-00904: "T"."IMAGE"."GETCONTENT": invalid identifier
ORA-06550: line 4, column 4:
PL/SQL: SQL Statement ignored
What is my problem?
I have Oracle interMedia 9.2.0.1.0 on Linux system, and I veryfied; ORDSYS.ORDImage have getcontent function that return BLOB.You should be using t.image.getcontent().....
declare
src BLOB;
BEGIN
Select t.image.getcontent() into src from imgtable t where t.id = 1;
END;
Or better yet (since you can access metadata, like mimetype this way):
declare
img ordsys.ordimage;
src BLOB;
begin
select t.image into img from imgtable t where t.id = 1;
src := img.getContent();
end; -
How does ORDImage.processCopy() works ?
Hi,
I'm using Oracle 10g r2.
I need to show ORDImages (and BLOBs).
Here is my procedure that shows thumbnails :
create or replace procedure show_photo_thumbnail(v_id_photo in number, v_height in number, v_width in number) as
obj ordsys.ordimage;
obj2 ordsys.ordimage;
begin
--obj2 := ordsys.ordimage.init();
select phot_source into obj from photos where phot_id = v_id_photo;
select phot_source into obj2 from photos where phot_id = v_id_photo for update;
obj.processcopy('maxscale= '||v_width||' '||v_height, obj2);
owa_util.mime_header(nvl(obj2.getmimetype(),'application/octet'), false );
htp.p('content-length: ' || obj2.getcontentlength());
htp.p('content-disposition: filename="' || obj2.source.srcname || '"');
owa_util.http_header_close;
wpg_docload.download_file(obj2.source.localdata);
commit;
end;It works, but if I call this function repeatedly (from our apex application), the image quality becomes less and less good, it seems it processes always the same image.
And for example if I call show_photo_thumbnail(1126, 150, 150) and then show_photo_thumbnail(1126, 500, 500), it seems the 500 x 500 image is processed from the 150 x 150 thumbnail so the quality is very poor.
I read the entire documentation and I really don't understand why.
By calling this other procedure we can see that the content stored stay unchanged :
procedure show_photo_infos(v_id_photo in number, v_height in number, v_width in number) as
obj ordsys.ordimage;
obj2 ordsys.ordimage;
begin
select phot_source into obj from photos where phot_id = v_id_photo;
select phot_source into obj2 from photos where phot_id = v_id_photo for update;
obj.processcopy('maxscale= '||v_width||' '||v_height, obj2);
dbms_output.put_line('obj : '||obj.getmimetype()||', '||obj.getcontentlength()||' bytes, '||obj.getwidth()||' x '||obj.getheight());
dbms_output.put_line('obj2 : '||obj2.getmimetype()||', '||obj2.getcontentlength()||' bytes, '||obj2.getwidth()||' x '||obj2.getHeight());
end;
show_photo_infos(1126, 200, 200);
obj : image/jpeg, 79754 bytes, 572 x 504
obj2 : image/jpeg, 4635 bytes, 200 x 176Any help would be much appreciated.
Thanks.
Yann.I was looking for a solution for this: I have a good quality (heavy) image stored in a BLOB. And i need a small, light version (a thumbnail) of that image for fast web page display. I have a table (pics) with the original BLOB picture (foto) and the BLOB column for the thumbnail (thumb) initialized as empty_blob(). This is the code that worked fine for me:
DECLARE
big_image blob;
small_image blob;
idm number;
BEGIN
idm:=10469; -- my id
big_image :=EMPTY_BLOB();
small_image :=EMPTY_BLOB();
SELECT foto,thumb INTO big_image ,small_image FROM pics
WHERE idpic = idm for update;
ORDSYS.ORDImage.processCopy(big_image,'maxscale=64 64', small_image);
UPDATE pics SET thumb = small_image
WHERE idpic = idm;
COMMIT;
EXCEPTION
WHEN ORDSYS.ORDImageExceptions.DATA_NOT_LOCAL THEN
DBMS_OUTPUT.PUT_LINE('Data is not local');
END; -
PL/SQL portlet with images
We use a Portal Form to load images into the database. The field in the database is a BLOB. We do not know how to display the imagefield in PL/SQL. Can anyone explain to us how we can solve this problem?
Lene & Anniken :o)procedure query_row(p_empno in varchar2 default null)
is
l_size integer;
l_imedia ordsys.ordimage;
l_tmpblob blob;
begin
htp.init;
select emp_image into l_imedia
from imedia.imtest1 where
empno = p_empno;
if l_imedia.islocal() then
owa_util.mime_header(l_imedia.getmimetype(),false,null);
htp.p('Pragma : no-cache');
htp.p('Cache-control: no-cache');
htp.p('Expires: Thu, 01 Jan 1970 12:00:00 GMT');
htp.p('Content-length: '||l_imedia.getcontentlength());
owa_util.http_header_close;
dbms_lob.createtemporary(l_tmpblob,true);
dbms_lob.copy(l_tmpblob,l_imedia.getcontent(),l_imedia.getcontentlength(),1,1);
wpg_docload.download_file(l_tmpblob);
dbms_lob.freetemporary(l_tmpblob);
else
owa_util.mime_header('text/html',false);
htp.p('Content-length: 0');
owa_util.http_header_close;
end if;
end query_row;
This example retrieves data from ordsys.ordimage datatype.
But if you are storing the data in blob, alter the above code something like the following :
wpg_docload.download_file(<blob_content>) -
Ordwebutl.cache_status
I can not find this procedure and not sure how to create it.
I am using OAS 4.0.8.1 on NT with Oracle 8.1.5
http_status := ordwebutl.cache_status( db_mod_date,http_if_modified_since,
http_last_modified );
I got this sample code "MP3demo" from technet.oracle.com
Can anyone help...
Thanks
null<oracle_home>\ord\web\admin\ordwebutl.sql
Rem Copyright (c) 1998, 1999 by Oracle Corp. All Rights Reserved.
Rem
Rem NAME
Rem ordwebutl
Rem
Rem PURPOSE
Rem Oracle interMedia Web Agent PL/SQL utility package
Rem
Rem USAGE
Rem sqlplus ordsys/<ordsys-password>@database @ordwebutl.sql
Rem -- OR --
Rem srvmgr> connect ordsys/<ordsys-password>@database
Rem svrmgr> @ordwebutl.sql
Rem
Rem HISTORY
Rem jcave 10/20/98 Initial version
Rem ddiamond 10/22/98 Add public synonym
Rem ddiamond 10/27/98 Remove the "; length=NNN" from date
Rem soxbury 11/17/98 Change name to ordwebutl; same as synonym
Rem soxbury 02/22/99 Add procedures to free temporary LOBs
Rem ddiamond 03/22/99 Add tables and procedures for IMW catalog
Rem
create table mw$catalog_by_typ (
TYPE_OWNER VARCHAR2(30)
not null,
TYPE_NAME VARCHAR2(30)
not null,
MEDIA_TYPE VARCHAR2(10)
not null,
LOB_TYPE VARCHAR2(10)
not null,
LOB_ATT VARCHAR2(100)
not null
create table mw$catalog_by_tab (
TABLE_OWNER VARCHAR2(30)
not null,
TABLE_NAME VARCHAR2(30)
not null,
KEY_COLUMN VARCHAR2(30)
not null,
INSERT_PROC VARCHAR2(30)
null,
UPDATE_PROC VARCHAR2(30)
null
create table mw$catalog_by_col (
TABLE_OWNER VARCHAR2(30)
not null,
TABLE_NAME VARCHAR2(30)
not null,
COLUMN_NAME VARCHAR2(30)
not null,
OBJ_GET_PROC VARCHAR2(30)
null,
OBJ_PUT_PROC VARCHAR2(30)
null,
OBJ_SET_PROC VARCHAR2(30)
null
delete from mw$catalog_by_typ where type_name = 'ORDAUDIO';
insert into mw$catalog_by_typ values (
'ORDSYS', 'ORDAUDIO', 'AUDIO', 'BLOB', '.SOURCE.LOCALDATA' );
delete from mw$catalog_by_typ where type_name = 'ORDIMAGE';
insert into mw$catalog_by_typ values (
'ORDSYS', 'ORDIMAGE', 'IMAGE', 'BLOB', '.SOURCE.LOCALDATA' );
delete from mw$catalog_by_typ where type_name = 'ORDVIDEO';
insert into mw$catalog_by_typ values (
'ORDSYS', 'ORDVIDEO', 'VIDEO', 'BLOB', '.SOURCE.LOCALDATA' );
delete from mw$catalog_by_typ where type_name = 'ORDIMGB';
insert into mw$catalog_by_typ values (
'ORDSYS', 'ORDIMGB', 'IMAGE', 'BLOB', '.CONTENT' );
delete from mw$catalog_by_typ where type_name = 'ORDVIR';
insert into mw$catalog_by_typ values (
'ORDSYS', 'ORDVIR', 'IMAGE', 'BLOB', '.IMAGE.SOURCE.LOCALDATA' );
commit work;
create or replace package ordsys.ordwebutl as
http_status_ok constant number(3) := 200; /* OK */
http_status_moved_perm constant number(3) := 301; /* Moved perm. */
http_status_moved_temp constant number(3) := 302; /* Moved temp. */
http_status_see_other constant number(3) := 303; /* See other */
http_status_not_mod constant number(3) := 304; /* Not modified */
http_status_forbidden constant number(3) := 403; /* Forbidden */
* Set dbms_server_timezone to the database server's time zone, if its
* one of the supported time zones (see new_date() SLQ function). If not
* supported, set dbms_server_gmtdiff to difference in hours from GMT.
dbms_server_timezone constant varchar2(3) := 'EST';
dbms_server_gmtdiff constant number := NULL;
function http_to_oracle_date( http_date in varchar2 ) return date;
function oracle_to_http_date( ora_date in date ) return varchar2;
function cache_status( db_lastmod_date in date,
cli_ifmod_date in varchar2,
cli_lastmod_date out varchar2 ) return number;
procedure free_temp_blob( temp_blob in out nocopy blob );
procedure free_temp_clob( temp_clob in out nocopy clob );
function get_imw_typ_media_type(
in_type_owner in varchar2,
in_type_name in varchar2 )
return varchar2;
function get_imw_typ_lob_type(
in_type_owner in varchar2,
in_type_name in varchar2 )
return varchar2;
function get_imw_typ_lob_att(
in_type_owner in varchar2,
in_type_name in varchar2 )
return varchar2;
procedure set_imw_typ_info(
in_type_owner in varchar2,
in_type_name in varchar2,
in_media_type in varchar2,
in_lob_type in varchar2,
in_lob_att in varchar2 );
function get_imw_tab_count(
in_table_name in varchar2 )
return number;
function get_imw_tab_key_column(
in_table_name in varchar2 )
retu rn varchar2;
function get_imw_tab_insert_proc(
in_table_name in varchar2 )
return varchar2;
function get_imw_tab_update_proc(
in_table_name in varchar2 )
return varchar2;
procedure set_imw_tab_info(
in_table_name in varchar2,
in_key_column in varchar2,
in_insert_proc in varchar2,
in_update_proc in varchar2 );
procedure set_imw_tab_key_column(
in_table_name in varchar2,
in_key_column in varchar2 );
procedure set_imw_tab_insert_proc(
in_table_name in varchar2,
in_insert_proc in varchar2 );
procedure set_imw_tab_update_proc(
in_table_name in varchar2,
in_update_proc in varchar2 );
function get_imw_col_obj_get_proc(
in_table_name in varchar2,
in_column_name in varchar2 )
return varchar2;
function get_imw_col_obj_put_proc(
in_table_name in varchar2,
in_column_name in varchar2 )
return varchar2;
function get_imw_col_obj_set_proc(
in_table_name in varchar2,
in_column_name in varchar2 )
return varchar2;
procedure set_imw_col_info(
in_table_name in varchar2,
in_column_name in varchar2,
in_obj_get_proc in varchar2,
in_obj_put_proc in varchar2,
in_obj_set_proc in varchar2 );
procedure set_imw_col_nothing(
in_table_name in varchar2,
in_column_name in varchar2 );
procedure set_imw_col_obj_get_proc(
in_table_name in varchar2,
in_column_name in varchar2,
in_obj_get_proc in varchar2 );
procedure set_imw_col_obj_put_proc(
in_table_name in varchar2,
in_column_name in varchar2,
in_obj_put_proc in varchar2 );
procedure set_imw_col_obj_set_proc(
in_table_name in varchar2,
in_column_name in varchar2,
in_obj_set_proc in varchar2 );
pragma restrict_references( http_to_oracle_date, WNDS, WNPS );
pragma restrict_references( oracle_to_http_date, WNDS, WNPS );
pragma restrict_references( cache_status, WNDS, WNPS );
pragma restrict_references( get_imw_typ_media_type, WNDS, WNPS );
pragma restrict_references( get_imw_typ_lob_type, WNDS, WNPS );
pragma restrict_references( get_imw_typ_lob_att, WNDS, WNPS );
pragma restrict_references( get_imw_tab_count, WNDS, WNPS );
pragma restrict_references( get_imw_tab_key_column, WNDS, WNPS );
pragma restrict_references( get_imw_tab_insert_proc, WNDS, WNPS );
pragma restrict_references( get_imw_tab_update_proc, WNDS, WNPS );
pragma restrict_references( get_imw_col_obj_get_proc, WNDS, WNPS );
pragma restrict_references( get_imw_col_obj_put_proc, WNDS, WNPS );
pragma restrict_references( get_imw_col_obj_set_proc, WNDS, WNPS );
end;
show errors;
create or replace package body ordsys.ordwebutl as
* Convert an HTTP GMT-based date to an Oracle date based on the database
* server's time zone. HTTP format: Wednesday, 25 Mar 1998 18:21:24 GMT
function http_to_oracle_date( http_date in varchar2 ) return date is
char_date varchar2( 64 );
char_pos integer;
ora_date date;
begin
if http_date is null
then
* Return NULL if no input date.
return null;
else
/* Start off with the original */
char_date := http_date;
* First strip off the "; length=NNN" the way the comments say we're
* supposed to. DLD, 10/27/98.
char_pos := instr( char_date, ';' );
if ( char_pos > 0 )
then
char_date := substr( char_date, 1, char_pos - 1 );
end if;
* Extract the part of the date we need, convert it to an Oracle date,
* then adjust to the database server's time zone.
char_pos := instr( char_date, ',' );
if (char_pos = 0)
then
* Must be an ANSI asctime() date
char_pos := instr( char_date, ' ');
char_date := substr( char_date, char_pos );
ora_date := TO_DATE( char_date, 'MON DD HH24:MI:SS YYYY' );
else
* RFC 822 or 850 date, or something similair
char_date := substr( char_date, char_pos+1 );
char_pos := instr( char_date, 'GMT' );
if ( LENGTH(char_date) < char_pos + 3)
then
char_date := substr( char_date, 1, char_pos-1 );
else
char_date := substr( char_date, 1, LENGTH(char_date)-3 );
end if;
ora_date := to_date( char_date, 'DD MON YYYY HH24:MI:SS' );
if to_char( ora_date, 'YYYY' ) < ' 0100'
then
ora_date := to_date( char_date, 'DD MON YY HH24:MI:SS' );
if (ora_date < TO_DATE('01/01/1980', 'MM/DD/YYYY'))
then
ora_date := add_months( ora_date, 1200 );
end if;
end if;
end if;
if (dbms_server_gmtdiff is not null)
then
return ora_date+(dbms_server_gmtdiff/24);
else
return new_time(ora_date,'GMT',dbms_server_timezone );
end if;
end if;
end;
* Convert an Oracle date based on the database server's time zone to an
* HTTP GMT-based date. HTTP format: Wednesday, 25 Mar 1998 18:21:24 GMT
function oracle_to_http_date( ora_date in date ) return varchar2 is
gmt_date date;
begin
if ora_date is null
then
* Return NULL if no input date.
return null;
else
* Convert time to GMT, then format as per HTTP standard.
if (dbms_server_gmtdiff is not null)
then
gmt_date := ora_date-(dbms_server_gmtdiff/24);
else
gmt_date := new_time(ora_date,dbms_server_timezone,'GMT');
end if;
return rtrim( substr( to_char( gmt_date, 'DAY' ), 1, 3 ) ) | |
', ' | |
to_char( gmt_date, 'DD MON YYYY HH24:MI:SS' ) | |
' GMT';
end if;
end;
* Figure out if a multi-media data item in a brower's cache is up to date.
* Currently, this algorithm bases its decision only on the date; it should
* also base the decision on the content length. Note the format of the
* request: If-Modified-Since: Monday, 23-Mar-98 19:46:10 GMT; length=66
* Currently, the entire string is passed to http_to_oracle_date(), which
* is kind enough just to pick out the date.
function cache_status( db_lastmod_date in date,
cli_ifmod_date in varchar2,
cli_lastmod_date out varchar2 ) return number is
cli_ifmod_date_local date;
begin
* Is there a last-modified date associated with the data? If not,
* there's nothing we can do.
if db_lastmod_date is not null
then
* If the browser is asking if the content has changed, then convert
* the if-modified date from GMT to local server time zone and
* compare with the modification date from the database. If the
* cache is still valid, then set the out-going last-modified date
* to NULL and return the not-modified status.
if cli_ifmod_date is not null
then
cli_ifmod_date_local := http_to_oracle_date( cli_ifmod_date );
if db_lastmod_date <= cli_ifmod_date_local
then
cli_lastmod_date := null;
return http_status_not_mod;
end if;
end if;
* Either the browser isn't asking if the cache is valid (because its
* not in the cache) or the cache is out of date. In either event,
* set the out-going last-modified date to modification date from
* database and return the OK status.
cli_lastmod_date := oracle_to_http_date( db_lastmod_date );
return http_status_ok;
else
* No modification date in the database, so no cache checking can
* be done; set the out-going last-modified date to NULL and return
* the OK status.
cli_lastmod_date := null;
return http_status_ok;
end if;
end;
* Procedures to free temporary LOBs.
procedure free_temp_blob( temp_blob in out nocopy blob ) is
begin
if dbms_lob.istemporary( temp_blob ) = 1 then
dbms_lob.freetemporary( temp_blob );
end if;
end;
procedure free_temp_clob( temp_clob in out nocopy clob ) is
begin
if dbms_lob.istemporary( temp_clob ) = 1 then
dbms_lob.freetemporary( temp_clob );
end if;
end;
* Clipboard procedures to access catalog.
function get_imw_typ_media_type(
in_type_owner in varchar2,
in_type_name in varchar2 )
return varchar2
is
ret_media_type varchar2(10);
begin
select media_type
into ret_media_type
from mw$catalog_by_typ t
where t.type_owner = in_type_owner
and t.type_name = in_type_name
and rownum = 1;
return ret_media_type;
end;
function get_imw_typ_lob_type(
in_type_owner in varchar2,
in_type_name in varchar2 )
return varchar2
is
ret_lob_type varchar2(10);
begin
select lob_type
into ret_lob_type
from mw$catalog_by_typ t
where t.type_owner = in_type_owner
and t.type_ name = in_type_name
and rownum = 1;
return ret_lob_type;
end;
function get_imw_typ_lob_att(
in_type_owner in varchar2,
in_type_name in varchar2 )
return varchar2
is
ret_lob_att varchar2(100);
begin
select lob_att
into ret_lob_att
from mw$catalog_by_typ t
where t.type_owner = in_type_owner
and t.type_name = in_type_name
and rownum = 1;
return ret_lob_att;
end;
procedure set_imw_typ_info(
in_type_owner in varchar2,
in_type_name in varchar2,
in_media_type in varchar2,
in_lob_type in varchar2,
in_lob_att in varchar2 )
is
counter int;
begin
select count(*)
into counter
from mw$catalog_by_typ t
where t.type_owner = in_type_owner
and t.type_name = in_type_name
and rownum = 1;
if counter = 0
then
insert into mw$catalog_by_typ values (
in_type_owner,
in_type_name,
in_media_type,
in_lob_type,
in_lob_att );
else
update mw$catalog_by_typ t set
media_type = in_media_type,
lob_type = in_lob_type,
lob_att = in_lob_att
where t.type_owner = in_type_owner
and t.type_name = in_type_name
and rownum = 1;
end if;
end;
function get_imw_tab_count(
in_table_name in varchar2 )
return number
is
ret_count int;
begin
select count(*)
into ret_count
from mw$catalog_by_tab t
where t.table_owner = user
and t.table_name = in_table_name;
return ret_count;
end;
function get_imw_tab_key_column(
in_table_name in varchar2 )
return varchar2
is
ret_key_column varchar2(30);
begin
select key_column
into ret_key_column
from mw$catalog_by_tab t
where t.table_owner = user
and t.table_name = in_table_name
and rownum = 1;
return ret_key_column;
end;
function get_imw_tab_insert_proc(
in_table_name in varchar2 )
return varchar2
is
ret_insert_proc varchar2(30);
begin
select insert_proc
into ret_insert_proc
from mw$catalog_by_tab t
where t.table_owner = user
and t.table_name = in_table_name
and rownum = 1;
return ret_insert_proc;
end;
function get_imw_tab_update_proc(
in_table_name in varchar2 )
return varchar2
is
ret_update_proc varchar2(30);
begin
select update_proc
into ret_update_proc
from mw$catalog_by_tab t
where t.table_owner = user
and t.table_name = in_table_name
and rownum = 1;
return ret_update_proc;
end;
procedure set_imw_tab_info(
in_table_name in varchar2,
in_key_column in varchar2,
in_insert_proc in varchar2,
in_update_proc in varchar2 )
is
counter int;
begin
select count(*)
into counter
from mw$catalog_by_tab t
where t.table_owner = user
and t.table_name = in_table_name
and rownum = 1;
if counter = 0
then
insert into mw$catalog_by_tab values (
user,
in_table_name,
in_key_column,
in_insert_proc,
in_update_proc );
else
update mw$catalog_by_tab t set
key_column = in_key_column,
insert_proc = in_insert_proc,
update_proc = in_update_proc
where t.table_owner = user
and t.table_name = in_table_name
and rownum = 1;
end if;
end;
procedure set_imw_tab_key_column(
in_table_name in varchar2,
in_key_column in varchar2 )
is
counter int;
begin
select count(*)
into counter
from mw$catalog_by_tab t
where t.table_owner = user
and t.table_name = in_table_name
and rownum = 1;
if counter = 0
then
insert into mw$catalog_by_tab (
table_owner,
table_name,
key_column )
values (
user,
in_table_name,
in_key_column );
else
update mw$catalog_by_tab t set
key_column = in_key_column
where t.table_owner = user
and t.table_name = in_table_name
and rownum = 1;
end if;
end;
procedure set_imw_tab_insert_proc(
in_table_name in varchar2,
in_insert_proc in varchar2 )
is
counter int;
begin
select count(*)
into counter
from mw$catalog_by_tab t
where t.table_owner = user
and t.table_name = in_table_name
and rownum = 1;
if counter = 0
then
insert into mw$catalog_by_tab (
table_owner,
table_name,
insert_proc )
values (
user,
in_table_name,
in_insert_proc );
else
update mw$catalog_by_tab t set
insert_proc = in_insert_proc
where t.table_owner = user
and t.table_name = in_table_name
and rownum = 1;
end if;
end;
procedure set_imw_tab_update_proc(
in_table_name in varchar2,
in_update_proc in varchar2 )
is
counter int;
begin
select count(*)
into counter
from mw$catalog_by_tab t
where t.table_owner = user
and t.table_name = in_table_name
and rownum = 1;
if counter = 0
then
insert into mw$catalog_by_tab (
table_owner,
table_name,
update_proc )
values (
user,
in_table_name,
in_update_proc );
else
update mw$catalog_by_tab t set
update_proc = in_update_proc
where t.table_owner = user
and t.table_name = in_table_name
and rownum = 1;
end if;
end;
function get_imw_col_obj_get_proc(
in_table_name in varchar2,
in_column_name in varchar2 )
return varchar2
is
ret_obj_get_proc varchar2(30);
begin
select obj_get_proc
into ret_obj_get_proc
from mw$catalog_by_col t
where t.table_owner = user
and t.table_name = in_table_name
and t.column_name = in_column_name
and rownum = 1;
return ret_obj_get_proc;
end;
function get_imw_col_obj_put_proc(
in_table_name in varchar2,
in_column_name in varchar2 )
return varchar2
is
ret_obj_put_proc varchar2(30);
begin
select obj_put_proc
into ret_obj_put_proc
from mw$catalog_by_col t
where t.table_owner = user
and t.table_name = in_table_name
and t.column_name = in_column_name
and rownum = 1;
return ret_obj_put_proc;
end;
function get_imw_col_obj_set_proc(
in_table_name in varchar2,
in_column_name in varchar2 )
return varchar2
is
ret_obj_set_proc varchar2(30);
begin
select obj_set_proc
into ret_obj_set_proc
from mw$catalog_by_col t
where t.table_owner = user
and t.table_name = in_table_name
and t.column_name = in_column_name
and rownum = 1;
return ret_obj_set_proc;
end;
procedure set_imw_col_info(
in_table_name in varchar2,
in_column_name in varchar2,
in_obj_get_proc in varchar2,
in_obj_put_proc in varchar2,
in_obj_set_proc in varchar2 )
is
counter int;
begin
select count(*)
into counter
from mw$catalog_by_col t
where t.table_owner = user
and t.table_name = in_table_name
and t.column_name = in_column_name
and rownum = 1;
if counter = 0
then
insert into mw$catalog_by_col values (
user,
in_table_name,
in_column_name,
in_obj_get_proc,
in_obj_put_proc,
in_obj_set_proc );
else
update mw$catalog_by_col t set
obj_get_proc = in_obj_get_proc,
obj_put_proc = in_obj_put_proc,
obj_set_proc = in_obj_set_proc
where t.table_owner = user
and t.table_name = in_table_name
and t.column_name = in_column_name
and rownum = 1;
end if;
end;
procedure set_imw_col_nothing(
in_table_name in varchar2,
in_column_name in varchar2 )
is
counter int;
begin
select count(*)
into counter
from mw$catalog_by_col t
where t.table_owner = user
and t.table_name = in_table_name
and t.column_name = in_column_name
and rownum = 1;
if counter = 0
then
insert into mw$catalog_by_col (
table_owner,
table_name,
column_name )
values (
user,
in_table_name,
in_column_name );
end if;
end;
procedure set_imw_col_obj_get_proc(
in_table_name in varchar2,
in_column_name in varchar2,
in_obj_get_proc in varchar2 )
is
counter int;
begin
select count(*)
into counter
from mw$catalog_by_col t
where t.table_owner = user
and t.table_name = in_table_name
and t.column_name = in_column_name
and rownum = 1;
if counter = 0
then
insert into mw$catalog_by_col (
table_owner,
table_name,
column_name,
obj_get_proc )
values (
user,
in_table_name,
in_column_name,
in_obj_get_proc );
else
update mw$catalog_by_col t set
obj_get_proc = in_obj_get_proc
where t.table_owner = user
and t.table_name = in_table_name
and t.column_name = in_column_name
and rownum = 1;
end if;
end;
procedure set_imw_col_obj_put_proc(
in_table_name in varchar2,
in_column_name in varchar2,
in_obj_put_proc in varchar2 )
is
counter int;
begin
select count(*)
into counter
from mw$catalog_by_col t
where t.table_owner = user
and t.table_name = in_table_name
and t.column_name = in_column_name
and rownum = 1;
if counter = 0
then
insert into mw$catalog_by_col (
table_owner,
table_name,
column_name,
obj_put_proc )
values (
user,
in_table_name,
in_column_name,
in_obj_put_proc );
else
update mw$catalog_by_col t set
obj_put_proc = in_obj_put_proc
where t.table_owner = user
and t.table_name = in_table_name
and t.column_name = in_column_name
and rownum = 1;
end if;
end;
procedure set_imw_col_obj_set_proc(
in_table_name in varchar2,
in_column_name in varchar2,
in_obj_set_proc in varchar2 )
is
counter int;
begin
select count(*)
into counter
from mw$catalog_by_col t
where t.table_owner = user
and t.table_name = in_table_name
and t.column_name = in_column_name
and rownum = 1;
if counter = 0
then
insert into mw$catalog_by_col (
table_owner,
table_name,
column_name,
obj_set_proc )
values (
user,
in_table_name,
in_column_name,
in_obj_set_proc );
else
update mw$catalog_by_col t set
obj_set_proc = in_obj_set_proc
where t.table_owner = user
and t.table_name = in_table_name
and t.column_name = in_column_name
and rownum = 1;
end if;
end;
end;
show errors;
CREATE PUBLIC SYNONYM ORDWEBUTL FOR ORDSYS.ORDWEBUTL;
GRANT EXECUTE ON ORDSYS.ORDWEBUTL TO PUBLIC;
null -
Where is fileDownload attribute?
Friends, I've repeated all steps from "Combining File Display Options" of the JHSDevGuide
pp 3-86, 3-87. Regenerate ... .
But I can't see any fileDownload attribute value:
In the Table view the column DownloadPhoto is EMPTY.
In the Form view there is no Attribute DownloadPhoto at all.
Where is my mistake?
Vladimir ZiminVladimir,
Could you provide some more information please, other than that it doesnt work? Like, are you using JSP or UIX, what is the column time (ordsys.ordimage, orddoc, blob), what code is implemented on the getDownloadPhoto() transient attribute, what are the 'Display' and 'Display Table' settings etc.?
Kind regards,
Peter Ebell
JHeadstart Team -
I am creating an apex app as part of a personal project and am a bit stuck.
I have created 2 procedures but I can't figure out how to make them run at the same time, I would ideally like to put them into one single procedure, but every time I try I end up with error warnings.
the procedures I have are as follows:
PROCEDURE 1
CREATE OR REPLACE PROCEDURE upload_new_image
(p_filename IN VARCHAR2)
IS
l_upload_size INTEGER;
l_upload_blob BLOB;
l_image_id NUMBER;
l_image ORDSYS.ORDImage;
BEGIN
-- Get the length, MIME type and the BLOB of the new image from the
-- upload table. apex_application_files is a synonym for WWV_FLOW_FILES
SELECT doc_size,
blob_content
INTO l_upload_size,
l_upload_blob
FROM apex_application_files
WHERE name = p_filename;
-- Insert a new row into the table, returning the newly allocated sequence
-- number from seq_image_id
INSERT INTO images
image_id,
filename,
image
VALUES
seq_image_id.nextval,
p_filename,
ORDSYS.ORDIMAGE.INIT()
RETURNING image_id
INTO l_image_id;
-- lock the row
SELECT image
INTO l_image
FROM images
WHERE image_id = l_image_id
FOR UPDATE;
-- copy the blob into the ORDImage BLOB container
DBMS_LOB.COPY( l_image.source.localData, l_upload_blob, l_upload_size );
l_image.setProperties(); -- just in case
UPDATE images
SET image = l_image
WHERE image_id = l_image_id;
-- clear from upload table
DELETE FROM apex_application_files
WHERE name = p_filename;
COMMIT;
EXCEPTION
WHEN others
THEN htp.p(SQLERRM);
END upload_new_image;PROCEDURE 2
CREATE OR REPLACE PROCEDURE create_blob_thumbnail (p_image_id IN INTEGER) IS
l_orig ORDSYS.ORDImage;
l_thumb ORDSYS.ORDImage;
l_blob_thumb BLOB;
BEGIN
-- lock row
SELECT image
INTO l_orig
FROM images
WHERE image_id = p_image_id FOR UPDATE;
l_thumb := ORDSYS.ORDImage.Init();
dbms_lob.createTemporary(l_thumb.source.localData, true);
ORDSYS.ORDImage.processCopy(l_orig,
'maxscale=128 128',
l_thumb);
UPDATE images
SET thumbnail = l_thumb.source.localData
WHERE image_id = p_image_id;
dbms_lob.freeTemporary(l_thumb.source.localData);
COMMIT;
END;Any help would be greatly appreciated
Edited by: BluShadow on 30-Nov-2012 14:45
added {noformat}{noformat} tags. Please read {message:id=9360002} and learn to do this yourself in future posts974264 wrote:
I have created 2 procedures but I can't figure out how to make them run at the same timeRunning things in parallel would require setting them running as scheduled jobs so they run in their own transactional sessions. You won't be able to run two procedures in parallel from the same session.
However you should certainly be able to combine two procedures into one if that is all you require. -
Hi Folks -
I have installed Oracle 11g and made a table like so:
CREATE TABLE files ...
"IMAGE_THUMB" "ORDIMAGE" ,
"VIDEO_THUMB" BLOB,
"CONTENT" "ORDDOC" ,
then do a DESC of the table and see this:
IMAGE_THUMB PUBLIC.ORDIMAGE
VIDEO_THUMB BLOB
CONTENT PUBLIC.ORDDOC
Usually it says "ORDSYS.ORDIMAGE" instead of PUBLIC.ORDIMAGE
What gives? I tried unlocking the ORDSYS account, and recreating the table using this:
"IMAGE_THUMB" "ORDSYS.ORDIMAGE" ,
ERROR at line 20:
ORA-00902: invalid datatype
How can I use the ORDSYS schema in 11g? I don't want this datatype owned by PUBLIC?The PUBLIC owner appears because the column was created using the ORDIMAGE synonym for the ORDSYS.ORDIMAGE type.
There's nothing wrong here, and no need to unlock or otherwise change the ORDSYS account. The ORDIMAGE type belongs to the ORDSYS schema
Try using "ORDSYS"."ORDIMAGE" if you want to see the ORDSYS schema when you do a describe. -
How to populate a table with ORDSYS.ORDImage item by BLOB item?
Hi, I have a table, that contain blob column and another table with ORDSYS.ORDImage column and I would like to populate ORDSYS.ORDImage item in table by BLOB item, in which I have store some images?
You should be able to do something like (this is off the top of my head, so please excuse any compile errors...):
define
b blob;
i ordsys.ordimage;
begin
INSERT INTO ordsysImgs VALUES (1,ORDSYS.ORDImage.init());
select imgCol into i from ordsysImgs where ID = 1 for update;
select blobcol into b from blobImgTable;
i.source.localdata := b;
i.setlocal();
i.setproperties();
update imgcol set imgCol = i where ID = 1;
commit;
end;
Maybe you are looking for
-
How can I install "Find my iPhone" on an old iPad 3?
I've recently gotten a new iPad, but my old iPad 3 is still working fine. So I've done a complete wipe on it and I've given it to a friend who has little interest in computing: she just wants to email and get on the internet. My friend will have to u
-
Java.lang.NullPointerException in MQ adapter in QA
Hi, My Process like Send the request to ResultsAAA(MQ queue) and Dequeue the msg req from the queue(ResultsAAA) and executing the bpel and we are configured Error Queue for no data.When I test it I got the following exexption in QA,please provide any
-
Stacked Canvas with one block displaying twice
I have a question regarding the Stacked Canvas. I have to create a calender for clients. (I am using stacked canvas to do that). In the 'calender' table i would have the information like ClientID, Year, weekno, start date, end date. So i created two
-
Finally. Someone PLEASE help me, really worried...
I was driving home and shut off my MacBook. When I got home, I started it backup, but it's in a safemode type of thing like windows... the OS starts up and for a second looks normal then it changed to all those weird colors, and my menus arent even c
-
Read Self Register Request using 11g API
Gurus, I am trying to read Self Register Request using API but I am getting beneficiaries and requester data as null. Can you please provide some code snippet to read beneficiary data from a Self Register Request.