Subject | Firebird 1.5: Statement failed, SQLCODE = -902. Internal error. |
---|---|
Author | Nando |
Post date | 2010-12-13T13:25:28Z |
Hi to all,
I'm testing a UDF compiled with FPC v.2.4.2. on a Linux CentOS 5.3 but I get a: "Statement failed, SQLCODE = -902. Internal error."
I've done double checked of the source code but I can't find what it is wrong with it. This is the source code:
{code}
library testudfs;
uses
ctypes,
SysUtils,
Classes,
DateUtils;
const
IBASE_DLL = 'fbclient.so';
type
// For dates
isc_quad = record
isc_quad_high: integer;
isc_quad_low: cardinal;
end;
PISC_QUAD = ^isc_quad; // Date
// C Date/Time Structure
TCTimeStructure = record
tm_sec: integer; // Seconds
tm_min: integer; // Minutes
tm_hour: integer; // Hour (0--23)
tm_mday: integer; // Day of month (1--31)
tm_mon: integer; // Month (0--11)
tm_year: integer; // Year (calendar year minus 1900)
tm_wday: integer; // Weekday (0--6) Sunday = 0)
tm_yday: integer; // Day of year (0--365)
tm_isdst: integer; // 0 if daylight savings time is not in effect)
end;
PCTimeStructure = ^TCTimeStructure;
procedure isc_decode_date(ib_date: PISC_QUAD; tm_date: PCTimeStructure);
cdecl; external IBASE_DLL;
procedure isc_encode_date(tm_date: PCTimeStructure; ib_date: PISC_QUAD);
cdecl; external IBASE_DLL;
function ib_util_malloc(l: integer): pointer; cdecl; external 'ib_util.so';
{ This are the declaration statements:
DROP EXTERNAL FUNCTION Test_01;
DECLARE EXTERNAL FUNCTION Test_01
TIMESTAMP
RETURNS INTEGER BY VALUE
ENTRY_POINT 'UDF_Test_01'
MODULE_NAME 'testudfs';
}
function UDF_Test_01(const FbDateTime: PISC_QUAD): Integer; cdecl; export;
var
PmyFbDateTime: PCTimeStructure;
myFbDateTime: TCTimeStructure;
begin
isc_decode_date(FbDateTime, PmyFbDateTime);
myFbDateTime := PMyFbDateTime^;
Result := myFbDateTime.tm_mday;
end;
exports
UDF_Test_01;
begin
end.
{code}
Any help will be appreciated,
Hernando.
I'm testing a UDF compiled with FPC v.2.4.2. on a Linux CentOS 5.3 but I get a: "Statement failed, SQLCODE = -902. Internal error."
I've done double checked of the source code but I can't find what it is wrong with it. This is the source code:
{code}
library testudfs;
uses
ctypes,
SysUtils,
Classes,
DateUtils;
const
IBASE_DLL = 'fbclient.so';
type
// For dates
isc_quad = record
isc_quad_high: integer;
isc_quad_low: cardinal;
end;
PISC_QUAD = ^isc_quad; // Date
// C Date/Time Structure
TCTimeStructure = record
tm_sec: integer; // Seconds
tm_min: integer; // Minutes
tm_hour: integer; // Hour (0--23)
tm_mday: integer; // Day of month (1--31)
tm_mon: integer; // Month (0--11)
tm_year: integer; // Year (calendar year minus 1900)
tm_wday: integer; // Weekday (0--6) Sunday = 0)
tm_yday: integer; // Day of year (0--365)
tm_isdst: integer; // 0 if daylight savings time is not in effect)
end;
PCTimeStructure = ^TCTimeStructure;
procedure isc_decode_date(ib_date: PISC_QUAD; tm_date: PCTimeStructure);
cdecl; external IBASE_DLL;
procedure isc_encode_date(tm_date: PCTimeStructure; ib_date: PISC_QUAD);
cdecl; external IBASE_DLL;
function ib_util_malloc(l: integer): pointer; cdecl; external 'ib_util.so';
{ This are the declaration statements:
DROP EXTERNAL FUNCTION Test_01;
DECLARE EXTERNAL FUNCTION Test_01
TIMESTAMP
RETURNS INTEGER BY VALUE
ENTRY_POINT 'UDF_Test_01'
MODULE_NAME 'testudfs';
}
function UDF_Test_01(const FbDateTime: PISC_QUAD): Integer; cdecl; export;
var
PmyFbDateTime: PCTimeStructure;
myFbDateTime: TCTimeStructure;
begin
isc_decode_date(FbDateTime, PmyFbDateTime);
myFbDateTime := PMyFbDateTime^;
Result := myFbDateTime.tm_mday;
end;
exports
UDF_Test_01;
begin
end.
{code}
Any help will be appreciated,
Hernando.