Passing BLOB / CLOB as a parameter to a PL / SQL function

I have this procedure I have my package:

PROCEDURE pr_export_blob (
    p_name IN VARCHAR2,
    p_blob IN BLOB,
    p_part_size IN NUMBER);

I would like the parameter to p_blobbe either BLOB or CLOB.

When I call this procedure with the BLOB parameter, everything is fine. When I call it using the CLOB parameter, I get a compilation error:

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 any of these types as a parameter? Maybe some superclass?

+3
source share
2

, 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);

, . , CLOB - BLOB, ,

+4

, , CLOB? CLOB 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;

( OTN).

+2

Source: https://habr.com/ru/post/1716686/


All Articles