Subject | Re: external functions in stored procedures |
---|---|
Author | Eric Merritt |
Post date | 2005-01-02T22:23:30Z |
> >--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>I pulled the declaration directly from ib_udf.sql.
> >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
>
> If the declaration you used is the one from ib_udf.sql then you have a
> configuration blind spot somewhere.
>
> -- what does your declaration look like?
However, here it is pulled from the database.
declare external function floor
double precision
returns double precision by value
entry_point 'IB_UDF_floor'
module_name 'ib_udf';
> -- What's your OS platform?Redhat Linux RHEL3
>Well, its resonably serious. I am using code from Joe Celko's 'Trees
> Is this a serious procedure or just a tryout for compiling?
and Hierarchies in Sql'. There is a bit of translation involved but
beyond that its pretty verbatim. I havn't really paid much attention
to the semantics yet becuse I have been dealing with getting it to
compile.
> When you do getprocedure will
> the library configuration sorted out, you'll find that this
> always go into an endless loop, since floor(intnum/2) will always beequal
> to (intnum/2), because of the way SQL integer division works. Hence,Hmm, thats interesting. I probably need to take a closer look at his
> floor() is meant to take and return doubles.
code and do a semantic translation instead of a syntactic translation.
> Try this instead, tho' it's a bit of mystery what it would be usefulfor:
>Its actually useful as a very small part of a rational number library
> 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
>
for an implementation of the nested intervals model for hierarchies a
RDBMS.