Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread External modules and date results
Fri, Sep 12 2008 7:12 AMPermanent Link

I wrote an external module to use dateutils.pas functions in database
procedures. All seems to work fine, but functions returning a date or
datetime value (DATE and TIMESTAMP in server side), always return
NULL.

Input DATE parameters arrive ok to the DLL, but returning DATE values
always fail.

See sample:

 if SameText(RoutineName,'StartOfTheMonth') then
//    Params.FindParam('Result').AsDate :=
DateUtils.StartOfTheMonth(Params.FindParam('aDate').AsDate)
   Params.FindParam('Result').AsDate := EncodeDate(2009,09,01)
 else
....

Funcion is declared as:

   EXECUTE IMMEDIATE 'CREATE FUNCTION "StartOfTheMonth" (IN aDate
DATE) RETURNS DATE
       EXTERNAL NAME "M01DateUtils";';


This function:

   EXECUTE IMMEDIATE 'CREATE FUNCTION "DaysInMonth" (IN aDate DATE)
RETURNS SMALLINT
       EXTERNAL NAME "M01DateUtils" DESCRIPTION ''Returns days in
aDate current month'';';

works fine, due IN date arrives ok, and SMALLINT result is posted ok
to database:

 if SameText(RoutineName,'DaysInMonth') then
   Params.FindParam('Result').AsInteger :=
     DateUtils.DaysInMonth(Params.FindParam('aDate').AsDate)

It's a bug? What's wrong?

I guess Params.FindParam('Result') is declared implicit, it's ok the
name "Result"?


Tiago Ameller
tiago put_an-a-_in_a_circle sistemasc.net
Sistema, S.C.
Fri, Sep 12 2008 7:41 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Tiago,

<< I wrote an external module to use dateutils.pas functions in database
procedures. All seems to work fine, but functions returning a date or
datetime value (DATE and TIMESTAMP in server side), always return NULL. >>

They seem to be working fine here B5.  You might be running into this issue
in B4 and earlier:

http://www.elevatesoft.com/incident?action=viewrep&category=edb&release=2.01&type=f&incident=2751

Due to the fact that we squash load exceptions currently, the end result is
that the return values are all NULL.

Are you testing this in the EDB Manager ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Fri, Sep 12 2008 8:00 AMPermanent Link

Tim,

>They seem to be working fine here B5.  You might be running into this issue
>in B4 and earlier:
>
>http://www.elevatesoft.com/incident?action=viewrep&category=edb&release=2.01&type=f&incident=2751

Ok, I'll make a copy of m01dateutils.dll with other name and define
first used function with one module and second used function with
other.

>Are you testing this in the EDB Manager ?

Yes.

Another related question. Trying to avoid using EntOfMonth function:

--  DECLARE wkDate DATE DEFAULT StartOfTheMonth(aDate); -- returns
NULL
--  DECLARE wkEndMonth DATE DEFAULT EndOfTheMonth(aDate); -- returns
NULL
 DECLARE iDays INTEGER DEFAULT DaysInMonth(aDate); -- works ok
 DECLARE wkDate DATE DEFAULT aDate; -- lets asume first day in month
as input
 DECLARE wkEndMonth DATE DEFAULT aDate + INTERVAL iDays DAY; --
calculate last day in month -- FAILS --

But INTERVAL iDays DAY fails (expected a constant not a vale). How can
I do this?


Tiago Ameller
tiago put_an-a-_in_a_circle sistemasc.net
Sistema, S.C.
Fri, Sep 12 2008 9:20 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Tiago,

<< But INTERVAL iDays DAY fails (expected a constant not a vale). How can I
do this? >>

You've got the syntax wrong - you can't use an INTERVAL constant expression
with a variable.  You need to use this instead:

DECLARE wkEndMonth DATE DEFAULT aDate + CAST(iDays AS INTERVAL DAY);

However, note that B4 has a bug with respect to casting INTEGER values to
INTERVALs:

http://www.elevatesoft.com/incident?action=viewrep&category=edb&release=2.01&type=f&incident=2756

--
Tim Young
Elevate Software
www.elevatesoft.com

Image