Subject | Re: UDF problem |
---|---|
Author | kittikira |
Post date | 2010-01-29T08:27:53Z |
I am still hanging with this problem.
I am not able to make any UDF with date parameters.
As sos as I call decode_date, or decode_sql_date, or decode_timestamp in my UDF, the firebird server is killed.
I looked at the examples, coming with firebird, but they even do not work.
I made a small example. Could anyone get this to work?
Here is the content of my example UDF source file.
#include <ib_util.h>
#include <ibase.h>
#include <time.h>
ISC_TIMESTAMP * first_day (ISC_TIMESTAMP *);
/* ---------------------------*/
ISC_TIMESTAMP * first_day (ISC_TIMESTAMP * d)
{
struct tm times;
decode_timestamp(d, ×);
tm1.tm_mday = 1;
isc_encode_sql_date(&tm1, d);
return d;
}
/*
declare external function FIRST_DAY
timestamp
returns timestamp
entry_point 'first_day' module_name 'rsudf'^
*/
When I just return the input parameter, then it works:
ISC_TIMESTAMP * first_day (ISC_TIMESTAMP * d)
{
return d;
}
As soon as i use
decode_timestamp(d, ×);
it crashes the server.
Would be really great, if someone could post an example how to make a working udf for date or timestamp parameters.
I would prefere date.
How about an working example that returns a date from 3 parameters passed to it, giving day, month and year?
I am not able to make any UDF with date parameters.
As sos as I call decode_date, or decode_sql_date, or decode_timestamp in my UDF, the firebird server is killed.
I looked at the examples, coming with firebird, but they even do not work.
I made a small example. Could anyone get this to work?
Here is the content of my example UDF source file.
#include <ib_util.h>
#include <ibase.h>
#include <time.h>
ISC_TIMESTAMP * first_day (ISC_TIMESTAMP *);
/* ---------------------------*/
ISC_TIMESTAMP * first_day (ISC_TIMESTAMP * d)
{
struct tm times;
decode_timestamp(d, ×);
tm1.tm_mday = 1;
isc_encode_sql_date(&tm1, d);
return d;
}
/*
declare external function FIRST_DAY
timestamp
returns timestamp
entry_point 'first_day' module_name 'rsudf'^
*/
When I just return the input parameter, then it works:
ISC_TIMESTAMP * first_day (ISC_TIMESTAMP * d)
{
return d;
}
As soon as i use
decode_timestamp(d, ×);
it crashes the server.
Would be really great, if someone could post an example how to make a working udf for date or timestamp parameters.
I would prefere date.
How about an working example that returns a date from 3 parameters passed to it, giving day, month and year?