Home » SQL & PL/SQL » SQL & PL/SQL » Instead of trigger not supporting blob (Oracle 11g)
Instead of trigger not supporting blob [message #613177] |
Wed, 30 April 2014 10:48 |
srinivas.k2005
Messages: 404 Registered: August 2006
|
Senior Member |
|
|
I have created the following table x_files_now and the view VW_x_files_now. My apex screen is based on this view VW_x_files_now. Whenever there is any insert on this view , The changes are inserted into x_files_now_a through instead of trigger. But BLOB_CONTENT are not getting inserted into the x_files_now_a table, it errors out unsupported feature returning class.Can you provide me solution of this issue
CREATE TABLE x_files_now
(
ID NUMBER PRIMARY KEY
,BLOB_CONTENT BLOB
,MIME_TYPE VARCHAR2 (255)
,FILENAME VARCHAR2 (255)
,LAST_UPDATED DATE
,CHARACTER_SET VARCHAR2 (128)
);
CREATE TABLE x_files_now_a
(
ID NUMBER
,BLOB_CONTENT BLOB
,MIME_TYPE VARCHAR2 (255)
,FILENAME VARCHAR2 (255)
,LAST_UPDATED DATE
,CHARACTER_SET VARCHAR2 (128)
,AUTH_STATUS VARCHAR2(10),
audit_group_id NUMBER
);
CREATE OR REPLACE VIEW VW_x_files_now AS SELECT
ID
,BLOB_CONTENT
,MIME_TYPE
,FILENAME
,LAST_UPDATED
,CHARACTER_SET
FROM x_files_now
CREATE OR REPLACE TRIGGER TRG_x_files_now INSTEAD OF
INSERT
ON VW_x_files_now FOR EACH ROW
DECLARE V_DML_TYPE VARCHAR2(1);
v_rowid varchar2(100);
BEGIN
IF INSERTING THEN
INSERT
INTO
x_files_now_A
(
ID
,BLOB_CONTENT
,MIME_TYPE
,FILENAME
,LAST_UPDATED
,CHARACTER_SET
)
VALUES
(
:NEW.ID
,EMPTY_BLOB()
,:NEW.MIME_TYPE
,:NEW.FILENAME
,:NEW.LAST_UPDATED
,:NEW.CHARACTER_SET
) RETURNING ROWID into v_rowid;
END IF;
END;
/
Thanks,
SRK
|
|
|
Re: Instead of trigger not supporting blob [message #613180 is a reply to message #613177] |
Wed, 30 April 2014 11:07 |
Solomon Yakobson
Messages: 3273 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
I can't reproduce it:
SQL> CREATE OR REPLACE TRIGGER TRG_x_files_now INSTEAD OF
2 INSERT
3 ON VW_x_files_now FOR EACH ROW
4 DECLARE V_DML_TYPE VARCHAR2(1);
5 v_rowid varchar2(100);
6 BEGIN
7
8 IF INSERTING THEN
9 INSERT
10 INTO
11 x_files_now_A
12 (
13 ID
14 ,BLOB_CONTENT
15 ,MIME_TYPE
16 ,FILENAME
17 ,LAST_UPDATED
18 ,CHARACTER_SET
19 )
20 VALUES
21 (
22 :NEW.ID
23 ,EMPTY_BLOB()
24 ,:NEW.MIME_TYPE
25 ,:NEW.FILENAME
26 ,:NEW.LAST_UPDATED
27 ,:NEW.CHARACTER_SET
28 ) RETURNING ROWID into v_rowid;
29
30 END IF;
31 END;
32 /
Trigger created.
SQL> insert
2 into VW_x_files_now
3 values(1,to_blob('1F'),'A','B',SYSDATE,'C')
4 /
1 row created.
SQL>
SY.
|
|
|
Re: Instead of trigger not supporting blob [message #613182 is a reply to message #613180] |
Wed, 30 April 2014 11:13 |
srinivas.k2005
Messages: 404 Registered: August 2006
|
Senior Member |
|
|
Sorry missed the below part.
When i try to insert the image file as below i am getting the error returning class not supported
DECLARE
l_dir VARCHAR2(10) := 'DEVDUMP'; ----> Is the Directory Object we created.
l_file VARCHAR2(20) := 'access.jpg'; ----- > The image to be located in the DB Server in the Directory Path DIR_NAME mentioned.
l_bfile BFILE ;
l_blob BLOB;
BEGIN
INSERT INTO VW_x_files_now (id, BLOB_CONTENT)
VALUES (26, empty_blob())
RETURN BLOB_CONTENT INTO l_blob;
l_bfile := BFILENAME(l_dir, l_file);
DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
DBMS_LOB.fileclose(l_bfile);
COMMIT;
END;
Thanks,
Srinivas
|
|
|
Re: Instead of trigger not supporting blob [message #613197 is a reply to message #613182] |
Wed, 30 April 2014 12:17 |
Solomon Yakobson
Messages: 3273 Registered: January 2010 Location: Connecticut, USA
|
Senior Member |
|
|
You can't use RETURNING clause with INSTEAD of triggers. It simply makes no sense. Instead of trigger can populate 10 different tables or no tables at all. And table it populates can have completely different columns comparing to view. You need to query table instead of trigger populates:
SQL> DECLARE
2 l_dir VARCHAR2(10) := 'TEMP'; ----> Is the Directory Object we created.
3 l_file VARCHAR2(20) := 'image.jpg'; ----- > The image to be located in the DB Server in the Directory Path DIR_NAME mentioned.
4 l_bfile BFILE ;
5 l_blob BLOB;
6 BEGIN
7 INSERT INTO VW_x_files_now (id, BLOB_CONTENT)
8 VALUES (26, empty_blob());
9 SELECT BLOB_CONTENT
10 INTO l_blob
11 FROM x_files_now_a
12 WHERE id = 26;
13
14 l_bfile := BFILENAME(l_dir, l_file);
15 DBMS_LOB.fileopen(l_bfile, DBMS_LOB.file_readonly);
16 DBMS_LOB.loadfromfile(l_blob, l_bfile, DBMS_LOB.getlength(l_bfile));
17 DBMS_LOB.fileclose(l_bfile);
18
19 COMMIT;
20 END;
21 /
PL/SQL procedure successfully completed.
SQL>
SY.
|
|
|
|
Goto Forum:
Current Time: Wed Apr 24 01:20:02 CDT 2024
|