oracle intermedia [message #238011] |
Wed, 16 May 2007 06:11 |
federicaintermedia
Messages: 6 Registered: May 2007
|
Junior Member |
|
|
hi All.
I'm using oracle intermedia and i would like to know if there's a way to extrapolate information about a Bfile.
Thanks in advance
Federica
|
|
|
|
Re: oracle intermedia [message #238257 is a reply to message #238011] |
Thu, 17 May 2007 04:07 |
federicaintermedia
Messages: 6 Registered: May 2007
|
Junior Member |
|
|
hi, i'm using oracle 10.0.2, the bfile are stored in a column of database and contain images. I want to use oracle intermedia to extrapolate for example the resolution of image.
thanks in advance
federica
|
|
|
Re: oracle intermedia [message #238402 is a reply to message #238257] |
Thu, 17 May 2007 16:38 |
|
Barbara Boehmer
Messages: 9100 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
I don't know of anything that gets resolution, but please see the demonstration below for one method of extracting some information.
scott@ORA92> CREATE TABLE your_tab
2 (id NUMBER,
3 your_bfile BFILE)
4 /
Table created.
scott@ORA92> CREATE OR REPLACE DIRECTORY your_dir AS 'd:\oracle2'
2 /
Directory created.
scott@ORA92> BEGIN
2 INSERT INTO your_tab (id, your_bfile)
3 VALUES (1, BFILENAME ('YOUR_DIR', 'clip.gif'));
4 INSERT INTO your_tab (id, your_bfile)
5 VALUES (2, BFILENAME ('YOUR_DIR', 'computercat.gif'));
6 INSERT INTO your_tab (id, your_bfile)
7 VALUES (3, BFILENAME ('YOUR_DIR', 'programmer_1.gif'));
8 COMMIT;
9 END;
10 /
PL/SQL procedure successfully completed.
scott@ORA92> DECLARE
2 v_dir_alias VARCHAR2 (4000);
3 v_filename VARCHAR2 (4000);
4 v_image ORDSYS.ORDImage;
5 v_path VARCHAR2 (4000);
6 BEGIN
7 DBMS_OUTPUT.PUT_LINE ('-------------------------------------------------');
8 FOR r IN
9 (SELECT id, your_bfile FROM your_tab)
10 LOOP
11 DBMS_LOB.FILEGETNAME (r.your_bfile, v_dir_alias, v_filename);
12 SELECT directory_path
13 INTO v_path
14 FROM all_directories
15 WHERE directory_name = v_dir_alias;
16 v_image := ORDSYS.ORDIMAGE.INIT ('FILE', v_dir_alias, v_filename);
17 v_image.setProperties();
18 DBMS_OUTPUT.PUT_LINE ('id: ' || r.id);
19 DBMS_OUTPUT.PUT_LINE ('directory: ' || v_dir_alias);
20 DBMS_OUTPUT.PUT_LINE ('path: ' || v_path);
21 DBMS_OUTPUT.PUT_LINE ('file name: ' || v_filename);
22 DBMS_OUTPUT.PUT_LINE ('width: ' || v_image.getWidth());
23 DBMS_OUTPUT.PUT_LINE ('height: ' || v_image.getHeight());
24 DBMS_OUTPUT.PUT_LINE ('size: ' || v_image.getContentLength());
25 DBMS_OUTPUT.PUT_LINE ('file type: ' || v_image.getFileFormat());
26 DBMS_OUTPUT.PUT_LINE ('type: ' || v_image.getContentFormat());
27 DBMS_OUTPUT.PUT_LINE ('compression: ' || v_image.getCompressionFormat());
28 DBMS_OUTPUT.PUT_LINE ('mime type: ' || v_image.getMimeType());
29 DBMS_OUTPUT.PUT_LINE ('-------------------------------------------------');
30 END LOOP;
31 END;
32 /
-------------------------------------------------
id: 1
directory: YOUR_DIR
path: d:\oracle2
file name: clip.gif
width: 11
height: 16
size: 73
file type: GIFF
type: 2BITLUTRGB
compression: GIFLZW
mime type: image/gif
-------------------------------------------------
id: 2
directory: YOUR_DIR
path: d:\oracle2
file name: computercat.gif
width: 280
height: 375
size: 68468
file type: GIFF
type: 8BITLUTRGB
compression: GIFLZW
mime type: image/gif
-------------------------------------------------
id: 3
directory: YOUR_DIR
path: d:\oracle2
file name: programmer_1.gif
width: 48
height: 48
size: 2068
file type: GIFF
type: 4BITLUTRGBT
compression: GIFLZW
mime type: image/gif
-------------------------------------------------
PL/SQL procedure successfully completed.
|
|
|
|
|
Re: oracle intermedia [message #241331 is a reply to message #238011] |
Tue, 29 May 2007 04:52 |
federicaintermedia
Messages: 6 Registered: May 2007
|
Junior Member |
|
|
Hi!this is my code in input:
set serveroutput on
set echo on
DECLARE
v_dir_alias VARCHAR2 (4000);
v_filename VARCHAR2 (4000);
v_image ORDSYS.ORDImage;
v_path VARCHAR2 (4000);
BEGIN
DBMS_OUTPUT.PUT_LINE ('-----------------------------------------------------');
FOR r IN
( SELECT id, my_bfile FROM RICORDI.PROVA_TAB )
LOOP
DBMS_LOB.FILEGETNAME (r.my_bfile, v_dir_alias, v_filename);
--SELECT directory_path
--INTO v_path
--FROM all_directories
--WHERE directory_name = v_dir_alias;
v_image := ORDSYS.ORDImage.init ('file', v_dir_alias, v_filename);
v_image.setProperties();
DBMS_OUTPUT.PUT_LINE ('id: ' || r.id);
DBMS_OUTPUT.PUT_LINE ('directory: ' || v_dir_alias);
DBMS_OUTPUT.PUT_LINE ('filename: ' || v_filename);
DBMS_OUTPUT.PUT_LINE('image width : ' || v_image.getWidth());
DBMS_OUTPUT.PUT_LINE ('height: ' || v_image.getHeight());
DBMS_OUTPUT.PUT_LINE ('size: ' || v_image.getContentLength());
DBMS_OUTPUT.PUT_LINE ('file type: ' || v_image.getFileFormat());
DBMS_OUTPUT.PUT_LINE ('type: ' || v_image.getContentFormat());
DBMS_OUTPUT.PUT_LINE ('compression: ' || v_image.getCompressionFormat());
DBMS_OUTPUT.PUT_LINE ('mime type: ' || v_image.getMimeType());
END LOOP;
END;
Output:
Connesso.
-----------------------------------------------------
DECLARE
*
ERRORE alla riga 1:
ORA-22285: non-existent directory or file for FILEOPEN operation
ORA-06512: at "ORDSYS.ORDIMG_PKG", line 814
ORA-06512: at "ORDSYS.ORDIMAGE", line 89
ORA-06512: at line 19
thanks for your help
|
|
|
Re: oracle intermedia [message #241870 is a reply to message #241331] |
Wed, 30 May 2007 15:04 |
|
Barbara Boehmer
Messages: 9100 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
The error is not due to anything in the code that you posted, but is due to a lack of privileges, probably read and write privileges on the directory object. Please see the reproduction and correction of the error below. Also, if you are going to use the code in a procedure, you must grant the privileges directly, not through a role.
-- reproduction of error:
scott@ORA92> SET ECHO ON
scott@ORA92> CREATE OR REPLACE DIRECTORY your_dir AS 'd:\oracle2'
2 /
Directory created.
scott@ORA92> CREATE USER ricordi IDENTIFIED BY ricordi
2 /
User created.
scott@ORA92> GRANT CONNECT, RESOURCE TO ricordi
2 /
Grant succeeded.
scott@ORA92> CREATE USER another IDENTIFIED BY another
2 /
User created.
scott@ORA92> GRANT CONNECT, RESOURCE TO another
2 /
Grant succeeded.
scott@ORA92> CONNECT ricordi/ricordi
Connected.
scott@ORA92> CREATE TABLE prova_tab
2 (id NUMBER,
3 my_bfile BFILE)
4 /
Table created.
scott@ORA92> BEGIN
2 INSERT INTO prova_tab (id, my_bfile)
3 VALUES (1, BFILENAME ('YOUR_DIR', 'clip.gif'));
4 INSERT INTO prova_tab (id, my_bfile)
5 VALUES (2, BFILENAME ('YOUR_DIR', 'computercat.gif'));
6 INSERT INTO prova_tab (id, my_bfile)
7 VALUES (3, BFILENAME ('YOUR_DIR', 'programmer_1.gif'));
8 COMMIT;
9 END;
10 /
PL/SQL procedure successfully completed.
scott@ORA92> GRANT SELECT ON prova_tab TO another
2 /
Grant succeeded.
scott@ORA92> CONNECT another/another
Connected.
scott@ORA92> SET SERVEROUTPUT ON
scott@ORA92> DECLARE
2 v_dir_alias VARCHAR2 (4000);
3 v_filename VARCHAR2 (4000);
4 v_image ORDSYS.ORDImage;
5 BEGIN
6 DBMS_OUTPUT.PUT_LINE ('-------------------------------------------------');
7 FOR r IN
8 (SELECT id, my_bfile FROM ricordi.prova_tab)
9 LOOP
10 DBMS_LOB.FILEGETNAME (r.my_bfile, v_dir_alias, v_filename);
11 v_image := ORDSYS.ORDIMAGE.INIT ('FILE', v_dir_alias, v_filename);
12 v_image.setProperties();
13 DBMS_OUTPUT.PUT_LINE ('id: ' || r.id);
14 DBMS_OUTPUT.PUT_LINE ('directory: ' || v_dir_alias);
15 DBMS_OUTPUT.PUT_LINE ('file name: ' || v_filename);
16 DBMS_OUTPUT.PUT_LINE ('width: ' || v_image.getWidth());
17 DBMS_OUTPUT.PUT_LINE ('height: ' || v_image.getHeight());
18 DBMS_OUTPUT.PUT_LINE ('size: ' || v_image.getContentLength());
19 DBMS_OUTPUT.PUT_LINE ('file type: ' || v_image.getFileFormat());
20 DBMS_OUTPUT.PUT_LINE ('type: ' || v_image.getContentFormat());
21 DBMS_OUTPUT.PUT_LINE ('compression: ' || v_image.getCompressionFormat());
22 DBMS_OUTPUT.PUT_LINE ('mime type: ' || v_image.getMimeType());
23 DBMS_OUTPUT.PUT_LINE ('-------------------------------------------------');
24 END LOOP;
25 END;
26 /
-------------------------------------------------
DECLARE
*
ERROR at line 1:
ORA-22285: non-existent directory or file for FILEOPEN operation
ORA-06512: at "ORDSYS.ORDIMG_PKG", line 608
ORA-06512: at "ORDSYS.ORDIMAGE", line 65
ORA-06512: at line 12
-- correction of error by granting privileges:
scott@ORA92> CONNECT scott/tiger
Connected.
scott@ORA92> GRANT READ, WRITE ON DIRECTORY your_dir TO another
2 /
Grant succeeded.
scott@ORA92> CONNECT another/another
Connected.
scott@ORA92> SET SERVEROUTPUT ON
scott@ORA92> DECLARE
2 v_dir_alias VARCHAR2 (4000);
3 v_filename VARCHAR2 (4000);
4 v_image ORDSYS.ORDImage;
5 BEGIN
6 DBMS_OUTPUT.PUT_LINE ('-------------------------------------------------');
7 FOR r IN
8 (SELECT id, my_bfile FROM ricordi.prova_tab)
9 LOOP
10 DBMS_LOB.FILEGETNAME (r.my_bfile, v_dir_alias, v_filename);
11 v_image := ORDSYS.ORDIMAGE.INIT ('FILE', v_dir_alias, v_filename);
12 v_image.setProperties();
13 DBMS_OUTPUT.PUT_LINE ('id: ' || r.id);
14 DBMS_OUTPUT.PUT_LINE ('directory: ' || v_dir_alias);
15 DBMS_OUTPUT.PUT_LINE ('file name: ' || v_filename);
16 DBMS_OUTPUT.PUT_LINE ('width: ' || v_image.getWidth());
17 DBMS_OUTPUT.PUT_LINE ('height: ' || v_image.getHeight());
18 DBMS_OUTPUT.PUT_LINE ('size: ' || v_image.getContentLength());
19 DBMS_OUTPUT.PUT_LINE ('file type: ' || v_image.getFileFormat());
20 DBMS_OUTPUT.PUT_LINE ('type: ' || v_image.getContentFormat());
21 DBMS_OUTPUT.PUT_LINE ('compression: ' || v_image.getCompressionFormat());
22 DBMS_OUTPUT.PUT_LINE ('mime type: ' || v_image.getMimeType());
23 DBMS_OUTPUT.PUT_LINE ('-------------------------------------------------');
24 END LOOP;
25 END;
26 /
-------------------------------------------------
id: 1
directory: YOUR_DIR
file name: clip.gif
width: 11
height: 16
size: 73
file type: GIFF
type: 2BITLUTRGB
compression: GIFLZW
mime type: image/gif
-------------------------------------------------
id: 2
directory: YOUR_DIR
file name: computercat.gif
width: 280
height: 375
size: 68468
file type: GIFF
type: 8BITLUTRGB
compression: GIFLZW
mime type: image/gif
-------------------------------------------------
id: 3
directory: YOUR_DIR
file name: programmer_1.gif
width: 48
height: 48
size: 2068
file type: GIFF
type: 4BITLUTRGBT
compression: GIFLZW
mime type: image/gif
-------------------------------------------------
PL/SQL procedure successfully completed.
scott@ORA92>
|
|
|
|