Skip to Main Content

SQL & PL/SQL

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!

Why am I getting this error?

492395Sep 29 2006 — edited Sep 29 2006
Hi folks,

I am trying to extract some CLOB data from the Portal schema, without much luck. I have written a procedure to write a CLOB to a textfile on the server, and when I try and loop through a cursor to call this procedure, I am getting the following error(s):

ORA-06510 unhandled user-defined exception

I realise what this means, but what puzzles me is I don't have any user defined exceptions in either procedures... Any help would be appreciated - code below:

CREATE OR REPLACE
PROCEDURE clob_to_file (p_dir IN VARCHAR2,
p_file IN VARCHAR2,
p_clob IN CLOB)
AS
l_output utl_file.file_type;
l_amt NUMBER DEFAULT 32000;
l_offset NUMBER DEFAULT 1;
l_length NUMBER DEFAULT NVL(dbms_lob.getlength(p_clob), 0);

BEGIN
l_output := utl_file.fopen(p_dir, p_file, 'w', 32760);
WHILE (l_offset < l_length)
LOOP
utl_file.put(l_output, dbms_lob.substr(p_clob, l_amt, l_offset));
utl_file.fflush(l_output);
l_offset := l_offset + l_amt;
END LOOP;
utl_file.new_line(l_output);
utl_file.fclose(l_output);

EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SUBSTR('Error: ' || TO_CHAR(SQLCODE) || ': ' || SQLERRM, 1, 255));
RAISE;
END;

SET SERVEROUTPUT ON SIZE 1000000;
SET LONG 1000000;
SET PAGESIZE 0;

DECLARE
v_username VARCHAR2(30) := 'username';
v_password VARCHAR2(30) := 'password';
v_text CLOB DEFAULT NULL;

-- cursor for CLOB data from Book of Regulations
CURSOR c_bor_clob IS
SELECT i.text
FROM wwsbr_all_items i
WHERE i.caid = 95
AND i.folder_region_id = 5182
AND i.itemtype = 'basetext'
AND i.subtype = '2'
AND i.is_current_version = 1;

BEGIN
wwctx_api.set_context(v_username, v_password);

OPEN c_bor_clob;
LOOP
FETCH c_bor_clob INTO
v_text;
EXIT WHEN c_bor_clob%NOTFOUND OR c_bor_clob%NOTFOUND IS NULL;
portal.clob_to_file('/home/oracle', 'zzzclob.txt', v_text);
END LOOP;
CLOSE c_bor_clob;

EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SUBSTR('Error: ' || TO_CHAR(SQLCODE) || ': ' || SQLERRM, 1, 255));
RAISE;
END;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 27 2006
Added on Sep 29 2006
30 comments
1,574 views