Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

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.



  


 Title: Clob in Trigger
 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

  




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 Khokhar857
  Mohammed Taj746
  positive fanatic483
  Jayanta Sur479
  Vigyan Kaushik386
  Vinoth Kumar357
  Gopu Gopi340
  Gitesh Trivedi322
  neeraj sharma258
  Ramesh Jois246






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software