[fpc-pascal] Firebird UDF

Codebue Fabio - P-Soft f.codebue at p-soft.biz
Thu Mar 13 08:31:32 CET 2008


This is my UDF source 

library pudf; 
  {$mode objfpc}{$H+} 
uses 
  Classes; 

function pround(var valore: real; ndec: integer):real;export; 
var 
  i: integer; 
  risultato: real; 
  ndivisore: integer; 
begin 
  risultato:= valore; 
  ndivisore:= 1; 
  for i:= 1 to ndec do 
  begin 
    risultato:= risultato*10; 
    ndivisore:= ndivisore*10; 
  end; 
  result:= round(risultato)/ndivisore; 
end; 

exports 
  pround name 'pround'; 

begin 
end. 

but after insert into my fdb with instruction 

DECLARE EXTERNAL FUNCTION pround 
DOUBLE PRECISION, INTEGER 
RETURNS DOUBLE PRECISION BY VALUE 
ENTRY_POINT 'pround' MODULE_NAME 'pudf'; 

if I use it with an instruction like this 

select round(123.1233, 2) as nrounded from rdb$database 

I have back this error 

Invalid token. 
invalid request BLR at offset 59. 
function PROUND is not defined. 
module name or entrypoint could not be found. 

do you have some idea regarding this error?

Codebue Fabio
.-----------------------------.
  _ \       __|       _||
  __/____|\__ \  _ \  _| _|
 _|       ____/\___/_| \__|

P-Soft di Codebue Fabio & C. sas
via B.Storti, 19
24060 - Chiuduno - BG
Italy
Phone: +39.030.839435
Fax: +39.030.5100306
Mobile: +39.348.3515786
.-----------------------------.
Web  : www.p-soft.biz
EMail: f.codebue at p-soft.biz  





More information about the fpc-pascal mailing list