Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Sizeof in PL/SQL

Re: Sizeof in PL/SQL

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Tue, 14 Dec 1999 22:00:34 +0800
Message-ID: <38564D82.6CDF@yahoo.com>


Andrew Protasov wrote:
>
> Thank you, Thomas
>
> But your solution modifies variable value also.
> In many cases it is not good. I need pure function.
>
> Andrew
>
> In article <ciea5sc035ofklsdv9n11tbb6m2mits20r_at_4ax.com>,
> tkyte_at_us.oracle.com wrote:
> > A copy of this was sent to Andrew Protasov <a_protasov_at_hotmail.com>
> > (if that email address didn't require changing)
> > On Mon, 13 Dec 1999 16:08:36 GMT, you wrote:
> >
> > >
> > >
> > >I know about this solution, but it is too slow for
> > >runtime. I need something faster.
> > >
> >
> > that'll be the fastest way to get that information. one way that does
> not use
> > the DD but is slower is:
> >
> > tkyte_at_8i> create or replace function sizeof( p_str in out varchar2 )
> return
> > number
> > 2 as
> > 3 l_size number default 0;
> > 4 l_str long default p_str;
> > 5 begin
> > 6 p_str := null;
> > 7 for i in 1 .. 32765 loop
> > 8 p_str := p_str || '*';
> > 9 l_size := i;
> > 10 end loop;
> > 11 exception
> > 12 when value_error then
> > 13 p_str := l_str;
> > 14 return l_size;
> > 15 end;
> > 16 /
> >
> > Function created.
> >
> > Other then that -- thats the only way to do it.
> >
> > >Andrew
> > >
> > >In article <38538064.6873_at_yahoo.com>,
> > > connor_mcdonald_at_yahoo.com wrote:
> > >> Andrew Protasov wrote:
> > >> >
> > >> > Hi,
> > >> >
> > >> > Is there anything similar to C sizeof function
> > >> > in PL/SQL? For example, if I have something
> > >> > like
> > >> >
> > >> > declare
> > >> > x varchar2(20);
> > >> > i integer;
> > >> > begin
> > >> > i:=sizeof(x);
> > >> > end;
> > >> >
> > >> > value of i must be always 20.
> > >> >
> > >> > There is vsize function, but it returns only
> > >> > current size, not maximum.
> > >> >
> > >> > I know how to get column length from all_tab_columns,
> > >> > but it is too slow.
> > >> >
> > >> > Andrew Protasov
> > >> >
> > >> > Sent via Deja.com http://www.deja.com/
> > >> > Before you buy.
> > >>
> > >> You could always have a look at the definition of all_tab_columsn
> in
> > >> dba_views and just pick out the bits you want to make it faster...
> > >> --
> > >> ===========================================
> > >> Connor McDonald
> > >> "These views mine, no-one elses etc etc"
> > >> connor_mcdonald_at_yahoo.com
> > >>
> > >> "Some days you're the pigeon, and some days you're the statue."
> > >>
> > >
> > >
> > >Sent via Deja.com http://www.deja.com/
> > >Before you buy.
> >
> > --
> > See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to
> Oracle8i'...
> > Current article is "Part I of V, Autonomous Transactions" updated June
> 21'st
> >
> > Thomas Kyte tkyte_at_us.oracle.com
> > Oracle Service Industries Reston, VA USA
> >
> > Opinions are mine and do not necessarily reflect those of Oracle
> Corporation
> >
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

I think Thomas has a typo in the code - use l_str instead of p_str and you'll find it does not modify the variable... --



Connor McDonald
"These views mine, no-one elses etc etc" connor_mcdonald_at_yahoo.com

"Some days you're the pigeon, and some days you're the statue." Received on Tue Dec 14 1999 - 08:00:34 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US