Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to calculate the length of a long raw field in plsql
Marco schrieb:
> Hi to all,
> is it any way to calculate the length of a very big fields in a long raw
> type in plsql?
> i found a lot of examples for long fields but i can't find the way for long
> raw.
>
> Merry Xmas
> best regards
> Marco
>
>
If your long raws are smaller than 32760 bytes, then utl_raw.length() will do it. If not, it seems , you are out of luck with plsql ( but still possible with pro*c/oci - see metalink note 1007848.6 ).
Another possibility could be with temporary conversion of long raw into blob and consequent using of dbms_lob (as pointed by DA Morgan):
SQL> set echo on SQL> set serveroutput on SQL> CREATE TABLE t(t1 LONG RAW);
Table created.
SQL> CREATE GLOBAL TEMPORARY TABLE tt(t1 BLOB);
Table created.
SQL>
SQL> DECLARE
2 l RAW(32767);
3 BEGIN
4 l:= utl_raw.copies('FF',32767);
5 INSERT INTO t VALUES(l);
6 END;
7 /
PL/SQL procedure successfully completed.
SQL>
SQL> DECLARE
2 n NUMBER;
3 BEGIN
4 INSERT INTO tt(t1)
5 SELECT to_lob(t1) FROM t;
6 SELECT dbms_lob.getlength(t1) INTO n FROM tt;
7 dbms_output.put_line(n);
8 END;
9 /
32767
PL/SQL procedure successfully completed.
Best regards
Maxim Received on Wed Jan 04 2006 - 08:43:19 CST
![]() |
![]() |