Subject Re: [ib-support] udf crashes firebird
Author Ivan Prenosil
From: "Nick Upson" <uebridger@...>
Subject: [ib-support] udf crashes firebird
> gratefull thanks to anyone who can tell me why
>
> /* ==============================================================
> fn_dowi() return the day of today as integer, Monday = 1, Sun = 7, etc
> ============================================================== */
> int fn_dowi()
> {
> struct tm tmem, *tbuf = &tmem;
>
> localtime_r(time(NULL), tbuf);
> return (tbuf->tm_wday);
> }

1) how does your UDF declaration look like ?
Do you use
... RETURNS INTEGER BY VALUE; ?

2) There is EXTRACT built-in function (not in IB4, IB5 though),
to return Monday = 1, .. Sun = 7, use it that way
EXTRACT(WEEKDAY FROM my_date_field - 1) + 1


Ivan Prenosil
[ I am looking for a job: InterBase - Firebird - Delphi - C - fulltext db - and more ... ]
Ivan.Prenosil@...
http://www.volny.cz/iprenosil/interbase