GETLENGTH v17

The GETLENGTH function returns the length of a large object.

<amount> NUMBER GETLENGTH(<lob_loc> BLOB)

<amount> NUMBER GETLENGTH(<lob_loc> CLOB)

<amount> NUMBER GETLENGTH(<file_loc> IN BFILE)

Parameters

amount

Length of the large object in bytes or characters.

file_loc

File locator for the BFILE whose length to obtain.

lob_loc

Large object locator of the large object whose length to obtain.

Example

DECLARE
   File_loc      BFILE = BFILENAME('ANOTHER_DIR', 'a.txt');
   Length        NUMBER;
BEGIN
   DBMS_LOB.OPEN(File_loc, DBMS_LOB.LOB_READONLY);
   /* Get the length of the LOB: */
   Length := DBMS_LOB.GETLENGTH(File_loc);
   IF Length IS NULL THEN
       DBMS_OUTPUT.PUT_LINE('BFILE is null.');
   ELSE
       DBMS_OUTPUT.PUT_LINE('The length is ' || length);
   END IF;
   /* Close the BFILE: */
   DBMS_LOB.CLOSE(File_loc);
END;