create or replace procedure test(v_s integer)
as
  v_CLOBlocator CLOB;
  v_BLOBlocator BLOB;
BEGIN
  -- Initializes the clob_col to the specified string, and returns the
  -- locator into v_LOBlocator.
  INSERT INTO lobdemo (key, clob_col)
    VALUES (20, 'abcdefghijklmnopqrstuvwxyz')
    RETURNING clob_col INTO v_CLOBlocator;  -- Modifies blob_col for the same row.
  UPDATE lobdemo
    SET blob_col = HEXTORAW('00FF00FF00FF')
    WHERE key = 20;  -- Retrieves the locator for the newly updated value, not the value
  -- itself.
  SELECT blob_col
    INTO v_BLOBlocator
    FROM lobdemo
    WHERE key = v_s;
END;
/

解决方案 »

  1.   

    CREATE OR REPLACE PROCEDURE LOBPrint(p_CLOB IN CLOB) AS
      v_Buffer VARCHAR2(80);
      v_Offset INTEGER := 1;
      v_Amount INTEGER := 80;
    BEGIN
      LOOP
        -- Read and output the next 80 characters.
        DBMS_LOB.READ(p_CLOB, v_Amount, v_Offset, v_Buffer);
        DBMS_OUTPUT.PUT_LINE(v_Buffer);    v_Offset := v_Offset + v_Amount;
      END LOOP;
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        -- End of loop, just return.
        NULL;
    END LOBPrint;
    /