Adriano,

> I like your opinion to not limit to only one input parameters. This limitation
> seems to not have sense.

I agree.

But then, would you agree that it is finally time for us to solve the problem 
of having to create multiple versions of a function to handle different data 
types.

Why can't there is a universal "parameter" or "variable" datatype which could 
be then interrogated (ie. TypeOf(variable)) by the function for its type and 
then the function can determine the runtime path it wants to follow.

Just as the INSERTING, UPDATING and DELETING Context variables allow for a 
single triggers to be defined for any table operation.

This would allow a function definition like:

create aggregate function custom_avg (
  i parameter
) returns (
  o double precision
) as
declare count bigint = 0;
declare accumulated double precision = 0;
begin

  If ( TypeOf( i) NOT IN (BINTINT, DECIMAL. DOUBLE PRECISION, INTEGER, NUMERIC, 
SMALLINT)) then
    Exception not_a_numeric_datatype;

  while (not agg_finished)
  do
  begin
    if (i is not null) then
    begin
      count = count + 1;
      accumulated = accumulated + i;
      o = accumulated / count;
    end

    suspend;
  end
end


Sean


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to