我有一个脚本应该打开一个xml文件并读取内容并进行处理。已成功创建plsql过程TEST_LOAD.BOB_LOAD。
TEST_LOAD.BOB_LOAD如下所示:
PROCEDURE BOB_LOAD(p_uuid IN varchar2,
xml_in IN xmltype,
msg_status OUT varchar2,
xml_out OUT xmltype);
END BOB_LOAD;
/
下面的脚本在最后一行调用此过程,似乎是错误的原因。我假设它没有将变量x识别为XMLTYPE。
DECLARE
xml_file UTL_FILE.FILE_TYPE;
chars_read INTEGER;
xml_clob CLOB;
xamount INTEGER :=32767;
char_buffer VARCHAR2(32767);
x XMLType;
BEGIN
xml_file := utl_file.fopen('/export/hm/testpit/bob', 'test.xml', 'r', xamount);
DBMS_LOB.CREATETEMPORARY(xml_clob, true);
LOOP
BEGIN
UTL_FILE.GET_LINE(xml_file, char_buffer);
chars_read :=LENGTH(char_buffer);
DBMS_LOB.WRITEAPPEND(xml_clob, chars_read, char_buffer);
DBMS_LOB.WRITEAPPEND(xml_clob, 1, CHR(10));
EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
END;
END LOOP;
UTL_FILE.FCLOSE(xml_file);
x := XMLType.createXML(xml_clob);
TEST_LOAD.BOB_LOAD('9718fa05-9995-4f17-jk1k-763113b8f4a4', x );
END;
/
然而,当我运行上面的脚本时,我得到一个ORA-06550,PLS:00306错误说:
ORA-06550: line 39, column 3:
PLS-00306: wrong number or types of arguments in call to 'BOB_LOAD'
ORA-06550: line 39, column 3:
PL/SQL: Statement ignored
答案 0 :(得分:2)
您的程序有4个参数。你只用它调用它。你需要用out参数调用它。
将文件内容读入CLOB的更简单方法:
function read_clob_from_file(p_directory varchar2
,p_filename varchar2) return clob is
l_amt number := dbms_lob.lobmaxsize;
l_dst_loc clob;
l_dst_offset number := 1;
l_lang_ctx number := dbms_lob.default_lang_ctx;
l_src_loc bfile;
l_src_offset number := 1;
l_warning number;
begin
l_src_loc := bfilename(p_directory, p_filename);
dbms_lob.createtemporary(l_dst_loc, true);
dbms_lob.fileopen(l_src_loc, dbms_lob.file_readonly);
dbms_lob.loadclobfromfile(l_dst_loc
,l_src_loc
,l_amt
,l_dst_offset
,l_src_offset
,dbms_lob.default_csid
,l_lang_ctx
,l_warning);
dbms_lob.fileclose(l_src_loc);
return l_dst_loc;
end;