Subject | Re: [firebird-support] Re: external functions in stored procedures |
---|---|
Author | Helen Borrie |
Post date | 2005-01-02T22:14:33Z |
At 08:58 PM 2/01/2005 +0000, you wrote:
configuration blind spot somewhere.
-- what does your declaration look like?
-- What's your OS platform?
the library configuration sorted out, you'll find that this procedure will
always go into an endless loop, since floor(intnum/2) will always be equal
to (intnum/2), because of the way SQL integer division works. Hence,
floor() is meant to take and return doubles.
Try this instead, tho' it's a bit of mystery what it would be useful for:
REcreate procedure find_numer_denom (
tnumer double precision,
tdenom double precision)
returns (
numer double precision,
denom double precision)
as
begin
numer = tnumer + 1;
denom = 2 * tdenom;
while (floor(numer/2) = numer / 2) do
begin
numer = numer / 2;
denom = denom / 2;
end
end
./hb
>--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>If the declaration you used is the one from ib_udf.sql then you have a
>wrote:
> > At 07:38 AM 2/01/2005 +0000, you wrote:
>
> > When do see an exception and what is the exception?
>
> At compile time.
>
>ISC ERROR MESSAGE:
>Dynamic SQL Error
>SQL error code = -804
>Function unknown
>FLOOR
configuration blind spot somewhere.
-- what does your declaration look like?
-- What's your OS platform?
>Is this a serious procedure or just a tryout for compiling? When you do get
> > >Do I need > >to declare it within the procedure somehow?
> >
> > No, only to the database. But maybe you are having difficulties because
> > you tried to compile the procedure before the function declaration was
> > committed?
>
> Could be. I can try that again.
>
>create procedure find_numer_denom (tnumer integer, tdenom integer)
>returns (numer integer, denom integer)
>as
>begin
> numer = tnumer + 1;
> denom = 2 * denom; /* this will result in null */
>
> while (floor(numer/2) = numer / 2) do
> begin
> numer = numer / 2;
> denom = denom / 2; /* will just be null */
> end
>end
the library configuration sorted out, you'll find that this procedure will
always go into an endless loop, since floor(intnum/2) will always be equal
to (intnum/2), because of the way SQL integer division works. Hence,
floor() is meant to take and return doubles.
Try this instead, tho' it's a bit of mystery what it would be useful for:
REcreate procedure find_numer_denom (
tnumer double precision,
tdenom double precision)
returns (
numer double precision,
denom double precision)
as
begin
numer = tnumer + 1;
denom = 2 * tdenom;
while (floor(numer/2) = numer / 2) do
begin
numer = numer / 2;
denom = denom / 2;
end
end
./hb