Subject | Re: Query question |
---|---|
Author | Adam |
Post date | 2005-01-20T23:58:54Z |
This uses a UDF, but you don't have to write or distribute anything,
the UDF comes pre-installed in Firebird, the following command will
declare it for you.
DECLARE EXTERNAL FUNCTION abs
DOUBLE PRECISION
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'IB_UDF_abs' MODULE_NAME 'ib_udf';
Then you should be able to use
select MyCol
from MyTable
order by abs(MyCol);
In theory you could create your own abs function using a simple
stored procedure, something like.
if InValue < 0 then
begin
OutValue = -1 * InValue;
end
else
begin
OutValue = InValue;
end
and may even be able to remove the UDF altogether, though IMO this is
a waste of time because the work is already done for you.
Adam
--- In firebird-support@yahoogroups.com, Robert martin <rob@c...>
wrote:
the UDF comes pre-installed in Firebird, the following command will
declare it for you.
DECLARE EXTERNAL FUNCTION abs
DOUBLE PRECISION
RETURNS DOUBLE PRECISION BY VALUE
ENTRY_POINT 'IB_UDF_abs' MODULE_NAME 'ib_udf';
Then you should be able to use
select MyCol
from MyTable
order by abs(MyCol);
In theory you could create your own abs function using a simple
stored procedure, something like.
if InValue < 0 then
begin
OutValue = -1 * InValue;
end
else
begin
OutValue = InValue;
end
and may even be able to remove the UDF altogether, though IMO this is
a waste of time because the work is already done for you.
Adam
--- In firebird-support@yahoogroups.com, Robert martin <rob@c...>
wrote:
> Hi Allresults
>
> With Standard firebird (no UDFs) is it possible to get a list of
> ordered numerically but ignoring negative signs.
>
> i.e.
>
> 5
> -6
> 7
> 8
> -9
> 10
>
> etc
>
> TIA
> Rob