Subject | UDF problem when I call isc_decode_date |
---|---|
Author | Marco Castroo |
Post date | 2009-02-16T12:24:43Z |
Hi,
Can someone help me on this? This function gets a date parameter and
returns a formated string data.
char * fn_RetornMonthYear(ISC_QUAD *d)
{
struct tm tm_date;
char *buffer = (char *)ib_util_malloc(8);
isc_decode_date(d, &tm_date);
strftime(buffer, 8 - 1, "%2.2m%4.4Y"+'\0', &tm_date);
return buffer;
}
The problem is at the isc_decode_date if it is not commented I get
this message in a Linux server (Fedora 7) running Firebird 2.1.
The dialect is 3. The size of sizeof(tm) is 44 bytes.
It returns a 8 bytes string, including \0 ("01/2009"). The malloc
alocs 8 bytes. I tried 1000 bytes with no difference in the error message.
The SQL statement to load the funcion is:
DECLARE EXTERNAL FUNCTION RETORNAMONTHYEAR
TIMESTAMP
RETURNS CSTRING(10) CHARACTER SET NONE FREE_IT
ENTRY_POINT 'fn_RetornaMonthYear' MODULE_NAME 'mcudflib';
The SQL error message is:
Statement failed, SQLCODE = -902
Unable to complete network request to host "localhost".
-Error reading data from the connection.
Thanks,
Marco Castro
Can someone help me on this? This function gets a date parameter and
returns a formated string data.
char * fn_RetornMonthYear(ISC_QUAD *d)
{
struct tm tm_date;
char *buffer = (char *)ib_util_malloc(8);
isc_decode_date(d, &tm_date);
strftime(buffer, 8 - 1, "%2.2m%4.4Y"+'\0', &tm_date);
return buffer;
}
The problem is at the isc_decode_date if it is not commented I get
this message in a Linux server (Fedora 7) running Firebird 2.1.
The dialect is 3. The size of sizeof(tm) is 44 bytes.
It returns a 8 bytes string, including \0 ("01/2009"). The malloc
alocs 8 bytes. I tried 1000 bytes with no difference in the error message.
The SQL statement to load the funcion is:
DECLARE EXTERNAL FUNCTION RETORNAMONTHYEAR
TIMESTAMP
RETURNS CSTRING(10) CHARACTER SET NONE FREE_IT
ENTRY_POINT 'fn_RetornaMonthYear' MODULE_NAME 'mcudflib';
The SQL error message is:
Statement failed, SQLCODE = -902
Unable to complete network request to host "localhost".
-Error reading data from the connection.
Thanks,
Marco Castro