Get the LENGTH of a LONG RAW

前端 未结 3 690
北荒
北荒 2020-12-01 21:39

I have a table with a column of data type LONG RAW. How do I determine the size (in bytes) of the data in this column?

If I call the LENGTH

3条回答
  •  情深已故
    2020-12-01 22:22

    As long as the data in the column does not exceed 16,383 bytes, you can solve this with a PL/SQL function, e.g.

    CREATE OR REPLACE FUNCTION get_lr_length (id IN NUMBER)
      RETURN NUMBER IS
      raw_data LONG RAW;
      hex_data VARCHAR2(32767);
      len      NUMBER;
    BEGIN
      SELECT my_long_raw_column INTO raw_data
      FROM my_table
      WHERE my_table.id = get_lr_length.id;
      hex_data := RAWTOHEX(raw_data);
      len := LENGTH(hex_data) / 2;
      RETURN len;
    END get_lr_length;
    

    Unfortunately, a LONG RAW can hold up to 2GB...

提交回复
热议问题