[英]Passing BLOB/CLOB as parameter to PL/SQL function
I have this procedure i my package: 我有这个程序我的包裹:
PROCEDURE pr_export_blob( p_name IN VARCHAR2, p_blob IN BLOB, p_part_size IN NUMBER);
I would like for parameter p_blob
to be either BLOB or CLOB. 我想参数
p_blob
是BLOB或CLOB。
When I call this procedure with BLOB parameter, everything is fine. 当我用BLOB参数调用这个过程时,一切都很好。 When I call it with CLOB parameter, I get compilation error:
当我用CLOB参数调用它时,我得到编译错误:
PLS-00306: wrong number or types of arguments in call to 'pr_export_blob'
Is there a way to write a procedure, that can take either of those types as parameter? 有没有办法编写一个过程,可以将这些类型中的任何一个作为参数? Some kind of a superclass maybe?
某种超级阶级可能吗?
Why don't you just overload the procedure to have a CLOB implementation as well 为什么不重载该过程以获得CLOB实现
PROCEDURE pr_export_lob(
p_name IN VARCHAR2,
p_blob IN BLOB,
p_part_size IN NUMBER);
PROCEDURE pr_export_lob(
p_name IN VARCHAR2,
p_clob IN CLOB,
p_part_size IN NUMBER);
You'll then need to work out the logic of what to do with in each procedure. 然后,您需要确定在每个过程中如何处理的逻辑。 As Colin says, a CLOB is not a BLOB - so I'm not sure what you plan to do with this
正如科林所说,CLOB不是BLOB - 所以我不确定你打算用这个做什么
Stupid question first, are you actually changing the procedure in the package to accept a CLOB? 首先是愚蠢的问题,你实际上是在改变程序包中的程序来接受CLOB吗? A CLOB is not interchangable with a BLOB.
CLOB不能与BLOB互换。
It is possible to convert a CLOB to BLOB : 可以将CLOB转换为BLOB :
create or replace procedure CLOB2BLOB (p_clob in out nocopy clob, p_blob in out nocopy blob) is
-- transforming CLOB â BLOB
l_off number default 1;
l_amt number default 4096;
l_offWrite number default 1;
l_amtWrite number;
l_str varchar2(4096 char);
begin
begin
loop
dbms_lob.read ( p_clob, l_amt, l_off, l_str );
l_amtWrite := utl_raw.length ( utl_raw.cast_to_raw( l_str) );
dbms_lob.write( p_blob, l_amtWrite, l_offWrite,
utl_raw.cast_to_raw( l_str ) );
l_offWrite := l_offWrite + l_amtWrite;
l_off := l_off + l_amt;
l_amt := 4096;
end loop;
exception
when no_data_found then
NULL;
end;
end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.