1

是否可以从特定表中连接 A1 和 A2(例如):

CREATE TABLE MY_SCHEME.CONC_BLOB
(
  A1       BLOB,
  A1_SORT  NUMBER(20),
  T_TYPE   VARCHAR2(9 BYTE),
  A2       BLOB,
  A2_SORT  NUMBER(20),
  A3       VARCHAR2(32 BYTE),
  A4       BLOB,
  A5       VARCHAR2(8 BYTE)
)

? 如何?

4

3 回答 3

3

BLOB 可以与 DBMS_LOB 包连接,特别是与 APPEND 过程连接。但是您将需要使用一些 PL/SQL 来迭代相关行并调用该过程。

我不太明白你说的下一张表是什么意思,所以我不能给你举个例子。

更新:

PL/SQL 的相关部分可能如下所示:

DECLARE
  a1_lob BLOB;
  a2_lob  BLOB;

BEGIN
  SELECT A1, A2 INTO a1_lob, a2_lob
  FROM CONC_BLOB
  WHERE A1_SORT = 'some value'
  FOR UPDATE;

  dbms_lob.append(a1_lob, a2_lob);
  COMMIT;
END;
于 2012-08-20T13:01:09.280 回答
1

仅供参考:如果您打算使用 blob 来存储大文本(这就是我想您想要连接它们的原因)我建议使用 CLOB。它将允许您使用 || 对于串联的最佳部分。不幸的是,您可能会遇到 || 的问题 当 clob 的长度超过 32767

于 2012-08-20T13:22:40.470 回答
1

Here is my solution for joining any number of BLOBs into single BLOB using helper table type and stored function:

create or replace type blobs as table of blob;

create or replace function concat_blobs(parts in blobs) return blob
is
    temp blob;
begin
    if parts is null or parts.count = 0 then
       return null;
    end if;
    dbms_lob.createtemporary(temp, false, dbms_lob.CALL);
    for i in parts.first .. parts.last
    loop
        dbms_lob.append(temp, parts(i));
    end loop;
    return temp;
end;

-- usage example:
select concat_blobs(blobs(to_blob(hextoraw('CAFE')), to_blob(hextoraw('BABE')))) from dual;


-- bonus
create or replace type raws as table of raw(2000);

create or replace function raws_to_blobs(arg in raws) return blobs
is
    res blobs;
begin
    select to_blob(column_value) bulk collect into res from table(arg);
    return res;
end;

-- usage example:
select concat_blobs(raws_to_blobs(raws(hextoraw('CAFE'), hextoraw('BABE'))) from dual;

See also multiple RAWs concatenation in Oracle 10: Using HEXTORAW to fill in blob data.

于 2020-06-02T22:17:55.017 回答