Topic: SQL*Plus and PL/SQL >> Clob in Trigger
|
Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property.
You may review the entire Oracle Certification Program Candidate Agreement online Here.
|
|
|
|
| milindb |
Posted: Feb 08, 2007 02:15:32 AM |
Total Post: 2
Joined: Aug, 2006
|
Hi All,
I have created row level insert trigger on REPORT table. It inserts the newly inserted record in REPORT_HISTORY table having same structure. REPORT table contains column Report_Query having CLOB datatype. Trigger works fine when length of CLOB is less than 4000. When it exceeds, trigger is unable to insert record in REPORT_QUERY column. Emply record for the CLOB column goes into it.
Here is the structure of tables.
REPORT:
REPORT_ID NUMBER,
NAME VARCHAR2(255),
DESCRIPTION VARCHAR2(255),
HTML_EXPORT NUMBER,
REPORT_QUERY CLOB,
DATASOURCE_ID NUMBER
REPORT_HISTORY:
Exactly same as table REPORT. One extra column REPORT_HIST_ID which is sequence for primary key.
TRIGGER:
CREATE OR REPLACE TRIGGER Report_History_Trigg
AFTER INSERT OR UPDATE ON REPORT
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
o_OutputStatus NUMBER;
o_OutputMessage VARCHAR2(1000);
v_ErrorFlag NUMBER;
v_REPORT_HIST_ID NUMBER;
BEGIN
v_ErrorFlag := 1;
SELECT REPORT_HIST_ID_SEQ.NEXTVAL INTO v_REPORT_HIST_ID FROM DUAL;
IF INSERTING THEN
INSERT INTO REPORT_HISTORY
(
REPORT_HIST_ID ,
REPORT_ID ,
NAME ,
DESCRIPTION ,
HTML_EXPORT ,
REPORT_QUERY ,
DATASOURCE_ID
)
VALUES
(
v_REPORT_HIST_ID,
:NEW.REPORT_ID ,
:NEW.NAME ,
:NEW.DESCRIPTION ,
:NEW.HTML_EXPORT ,
:NEW.REPORT_QUERY,
:NEW.DATASOURCE_ID
);
END IF;
v_ErrorFlag := 2;
IF UPDATING THEN
IF TRIM(:NEW.REPORT_QUERY) <> TRIM(:OLD.REPORT_QUERY) THEN
INSERT INTO REPORT_HISTORY
(
REPORT_HIST_ID ,
REPORT_ID ,
NAME ,
DESCRIPTION ,
HTML_EXPORT ,
REPORT_QUERY ,
DATASOURCE_ID
)
VALUES
(
v_REPORT_HIST_ID,
:NEW.REPORT_ID ,
:NEW.NAME ,
:NEW.DESCRIPTION ,
:NEW.HTML_EXPORT ,
:NEW.REPORT_QUERY,
:NEW.DATASOURCE_ID
);
ND IF;
o_OutputStatus := 0;
o_OutputMessage := 'SUCCESS';
EXCEPTION
WHEN OTHERS THEN
o_OutputStatus := 1;
o_OutputMessage :='Operation Failed. Step No = '||v_ErrorFlag||' Sql Error :- '||SUBSTR(SQLERRM,1,100) ;
END;
Can anybody give the solution for problem?
Thanks and Regards,
Milind.
|
|
|
| Time Zone: EDT |
Send this thread to your friend |
|
|
|
|
Forum Rules & Description
Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user
|
| |
Get FREE Magazines
|
Top 10 Forum User
|
| Murtuja Khokhar | 857 |
| Mohammed Taj | 746 |
| positive fanatic | 483 |
| Jayanta Sur | 479 |
| Vigyan Kaushik | 386 |
| Vinoth Kumar | 357 |
| Gopu Gopi | 340 |
| Gitesh Trivedi | 322 |
| neeraj sharma | 258 |
| Ramesh Jois | 246 |
|
|