create or replace function getClobDocument(filename in varchar2, charset in varchar2 default NULL)
return CLOB deterministic
is
file bfile := bfilename('d:/',filename);
charContent CLOB := ' ';
targetFile bfile;
lang_ctx number := DBMS_LOB.default_lang_ctx;
charset_id number := 0;
src_offset number := 1 ;
dst_offset number := 1 ;
warning number;
begin if charset is not null then
charset_id := NLS_CHARSET_ID(charset);
end if;
targetFile := file;
DBMS_LOB.fileopen(targetFile, DBMS_LOB.file_readonly);
DBMS_LOB.LOADCLOBFROMFILE(charContent, targetFile, BMS_LOB.getLength(targetFile), src_offset,dst_offset,charset_id, lang_ctx,warning);
DBMS_LOB.fileclose(targetFile);
return charContent; end; /
return CLOB deterministic
is
file bfile := bfilename('d:/',filename);
charContent CLOB := ' ';
targetFile bfile;
lang_ctx number := DBMS_LOB.default_lang_ctx;
charset_id number := 0;
src_offset number := 1 ;
dst_offset number := 1 ;
warning number;
begin if charset is not null then
charset_id := NLS_CHARSET_ID(charset);
end if;
targetFile := file;
DBMS_LOB.fileopen(targetFile, DBMS_LOB.file_readonly);
DBMS_LOB.LOADCLOBFROMFILE(charContent, targetFile, BMS_LOB.getLength(targetFile), src_offset,dst_offset,charset_id, lang_ctx,warning);
DBMS_LOB.fileclose(targetFile);
return charContent; end; /
本文介绍了一个PL/SQL函数getClobDocument,该函数用于将指定路径的文件内容读取为CLOB类型。函数支持指定字符集,并通过DBMS_LOB包进行文件读取和内容转换。
1053

被折叠的 条评论
为什么被折叠?



