Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Plain text from RTF - ctx_doc.filter

bruno2Sep 3 2012 — edited Sep 4 2012
Hello,

starting from the documentation (http://docs.oracle.com/cd/E11882_01/text.112/e24436/cdocpkg.htm#i997868) I'm trying to write a function which would convert RTF stored in CLOB in some table into plain text. Here's where I got so far with a test case:

CREATE TABLE rtf_table (id NUMBER PRIMARY KEY, rtf CLOB)
/
INSERT INTO rtf_table
VALUES (1,
'{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset238 CorporateSLight;}}
\viewkind4\uc1\pard\lang1050\f0\fs24\ This is
\par regular rtf file
\par spanning
\par several
\par lines...
\par The End
\par }' )
/
COMMIT
/
CREATE INDEX ix_ctx_rtf ON rtf_table (rtf)
INDEXTYPE IS ctxsys.CONTEXT PARAMETERS ('filter ctxsys.null_filter')
/

CREATE OR REPLACE FUNCTION get_rtf (
p_id IN NUMBER,
p_plain IN NUMBER
)
RETURN VARCHAR2
IS
mklob CLOB;
amt NUMBER := 40;
line VARCHAR2 (80);
plain BOOLEAN;
BEGIN
IF p_plain = 0
THEN
plain := FALSE;
ELSE
plain := TRUE;
END IF;

ctx_doc.filter ('IX_CTX_RTF', p_id, mklob, plain);
-- mklob is NULL when passed-in, so ctx-doc.filter will allocate a temporary
-- CLOB for us and place the results there.
DBMS_LOB.READ (mklob, amt, 1, line);
-- have to de-allocate the temp lob
DBMS_LOB.freetemporary (mklob);
RETURN line;
END;
/

SELECT a.*, get_rtf (a.id, 1) AS plain,
get_rtf (a.id, 0) AS other
FROM rtf_table a
/

ID RTF PLAIN OTHER
-------------------------------------- ---------- ------------------------------------------------ ------------------------------------------------
1 (CLOB) {\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcha {\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcha

1 row(s) retrieved


As you can see, I cannot get plain text out. I am probably missing something obvious but I just can't figure it out.

Thanks in advance,
Bruno
This post has been answered by Roger Ford-Oracle on Sep 3 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 2 2012
Added on Sep 3 2012
5 comments
3,521 views