Discussions
Categories
- 196.7K All Categories
- 2.2K Data
- 235 Big Data Appliance
- 1.9K Data Science
- 449.8K Databases
- 221.6K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 549 MySQL Community Space
- 477 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 532 SQLcl
- 4K SQL Developer Data Modeler
- 186.9K SQL & PL/SQL
- 21.3K SQL Developer
- 295.4K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.1K Development Tools
- 104 DevOps
- 3.1K QA/Testing
- 645.9K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 153 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 17 Java Essentials
- 158 Java 8 Questions
- 85.9K Java Programming
- 79 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.2K Java SE
- 13.8K Java Security
- 203 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 395 LiveLabs
- 37 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.6K Other Languages
- 2.3K Chinese
- 170 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 230 Portuguese
Insert ORDImage using WORKSPACE_IMAGES ?

Yann39
Member Posts: 537
Hi,
I work with Oracle 10g r2 and APEX 3.2 on Windows XP Pro.
I have tables using ORDImage data type (for logos), and I want to allow users to insert rows.
So I have created a procedure to insert ORDImages :
-----
CREATE OR REPLACE PROCEDURE insert_logo(dest_id NUMBER, filename VARCHAR2) IS
img ordsys.ordimage;
ctx raw(64) := null;
BEGIN
SELECT logo INTO img FROM Marque WHERE id=dest_id FOR UPDATE;
img.importFrom(ctx, 'file', v('WORKSPACE_IMAGES'), filename);
UPDATE Marque SET logo=img WHERE id=dest_id;
END;
*/*
-----
succesfully created.
But when I run it by exec insert_logo(2,'logo_Gigabyte.jpg');, it show me the ORA-30625 error.
can't I use v('WORKSPACE_IMAGES') for images directory ?
I tried : CREATE OR REPLACE directory images AS v('WORKSPACE_IMAGES'); but don't work too.
any help ?
Thanks !
I work with Oracle 10g r2 and APEX 3.2 on Windows XP Pro.
I have tables using ORDImage data type (for logos), and I want to allow users to insert rows.
So I have created a procedure to insert ORDImages :
-----
CREATE OR REPLACE PROCEDURE insert_logo(dest_id NUMBER, filename VARCHAR2) IS
img ordsys.ordimage;
ctx raw(64) := null;
BEGIN
SELECT logo INTO img FROM Marque WHERE id=dest_id FOR UPDATE;
img.importFrom(ctx, 'file', v('WORKSPACE_IMAGES'), filename);
UPDATE Marque SET logo=img WHERE id=dest_id;
END;
*/*
-----
succesfully created.
But when I run it by exec insert_logo(2,'logo_Gigabyte.jpg');, it show me the ORA-30625 error.
can't I use v('WORKSPACE_IMAGES') for images directory ?
I tried : CREATE OR REPLACE directory images AS v('WORKSPACE_IMAGES'); but don't work too.
any help ?
Thanks !
Answers
-
Yann39 wrote:Hi,
can't I use v('WORKSPACE_IMAGES') for images directory ?
I tried : CREATE OR REPLACE directory images AS v('WORKSPACE_IMAGES'); but don't work too.
any help ?
No, you can not use #WORKSPACE_IMAGES# that way.
WORKSPACE_IMAGES points to apex system table that hold your files you upload to workspace.
Br,Jari
Edited by: jarola on Feb 4, 2010 8:23 PM
This may help you to right direction
http://download.oracle.com/docs/cd/E14373_01/appdev.32/e13363/up_dn_files.htm#CIHHEHCJ
Also if you install Demonstrative application, you can see example from page 6
To install Demo app:
Home>Application Builder>Create
and select Demonstration Application -
Arf, so I have to convert BLOB to ORDImage ? Is there any way to do that ?
thx. -
Arf, so I have to convert BLOB to ORDImage ? Is there any way to do that ?Yes, there is an [ORDImage constructor for BLOBs|http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10776/ch_imgref.htm#CHDDFGJC].
-
OK thank you
I tried that :
INSERT INTO Marque(logo)
SELECT ORDSYS.ORDImage(t.BLOB_CONTENT) FROM APEX_APPLICATION_FILES t WHERE t.FILENAME = 'logo_Gigabyte.jpg';
But I have the ORA-02315 error : incorrect number of arguments for default constructor.
In the example below it seems to work :
http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10776/ch_imgref.htm#CHDDFGJC
I forget something ? -
Sorry, I didn't spot that you were one of those rare people who actually identifies their DB version up front. The doc I linked to was for 11.2: that BLOB constructor doesn't exist in 10.2.
-
ohh nooooooo
I will search for an other solution.
If isomeone thinks of something interresting do not hesitate !
Thank you fac586 -
OK I think "I" have found :
I updated my logo field to intialize ordimage with empty constructor :
update Marque set logo = ordsys.ordimage.init();
Then copy apex blob image data into the blob storage of the ordimage column of my table (here just for the row id=2) :
update marque m set m.logo.source.localdata = (select t.BLOB_CONTENT FROM APEX_APPLICATION_FILES t WHERE t.FILENAME = 'logo_Gigabyte.jpg') WHERE id=2;
Then loop through images to set properties (here just for row id=2, loop don't needed) :
begin
for rec in (select id, logo from marque where id=2) loop
rec.logo.setProperties();
update marque set logo = rec.logo where id = rec.id;
end loop;
end;
And finnaly show informations :
DECLARE
image ORDImage;
idnum integer;
rowcount integer;
BEGIN
SELECT id, logo into idnum, image from marque where id=2;
dbms_output.put_line('-------------------------------------------');
dbms_output.put_line('image id: '|| idnum);
dbms_output.put_line('image height: '|| image.getHeight());
dbms_output.put_line('image width: '|| image.getWidth());
dbms_output.put_line('image MIME type: '|| image.getMimeType());
dbms_output.put_line('image file format: '|| image.getFileFormat());
dbms_output.put_line('BLOB Length: '|| TO_CHAR(image.getContentLength()));
dbms_output.put_line('-------------------------------------------');
END;
/
Result :
-------------------------------------------
image id: 2
image height: 162
image width: 180
image MIME type: image/jpeg
image file format: JFIF
BLOB Length: 8601
-------------------------------------------
Properties are good, it seems to work !
I found some information on the following thread : http://kr.forums.oracle.com/forums/thread.jspa?threadID=443410&start=0&tstart=0, thanks to us.
I will try to show images now, and I will make more tests before marking this post as answered
Thanks.
Yann. -
Hi,
just a last question :
is it possible to show an ORDImage (in a region) using only PL/SQL ? I don't find any information on the net.
or should I use a Java component ?
Thanks. -
Search the forum for "ORDImage". I think all/most of the posts deal with using the ORDImage static methods on BLOBs, but there may be something relevant. Otherwise just look for stuff about displaying images from BLOBs: it's all really the same.
(Too busy to dive into this in depth at present.) -
OK thanks for the tip.
I will try some things I have found, it should work.
Bye
This discussion has been closed.