quicker way to find the length of a record

From: Oxnard Montalvo <oxnard_at_carolina.rr.com>
Date: Sat, 23 Feb 2008 11:14:58 -0500
Message-ID: <17448408.235281203783298451.JavaMail.root@cdptpa-web20-z02>

version 10r2

 type rec_type is record(
   c1 varchar2(1) not null := 'D'
   ,c2 number not null := 12345
 rec rec_type;
 type t is table of number index by pls_integer;  c t;
 type rec2 is record(
  c1 number
  ,c2 varchar2(10));
 type rec2_type is table of rec2 index by pls_integer;  c2 rec2_type;
 select col bulk collect into c from
(select 121212121212121212129999 as col from dual
  union all
  select 221212121212121212121212121212 as col from dual);  dbms_output.put_line(length(c(1)));  

 select c1,c2 bulk collect into c2 from
(select 1 as c1,'bbbb' as c2 from dual

  union all
  select 2 as c1,'dkkdk' as c2 from dual);      

  • dbms_output.put_line(length(c2(1))); -- fails
  • dbms_output.put_line(length(rec)); -- fails

 dbms_output.put_line((length(rec.c1) + length(rec.c2))); -- works but a pain   


seems like the only way to obtain the length is to add all the pieces. The adding is not bad on small records but large one is a bit of a pain. Any way which would use less code to do this?


Received on Sat Feb 23 2008 - 10:14:58 CST

Original text of this message