Subject Re: [IBO] TIBOStoredProc still working correctly?
Author Luiz Alves
> with dbData.spGetLastAppointment do begin
> Params.ParamValues['PERSONID'] := PersonID;
> Prepare;
> ExecSQL;

You are calling prepare after assign values to params. You can change it to:
if not Prepared then Prepare;
Params.ParamValues['PERSONID'] := PersonID;
ExecSQL;


Another thing is that was related on past an bug with Variants.

So, You could try the same with :

SP.ParamByname('xx').asXXXXX:=YYYY

and see if it help you.

Luiz.
Luiz.

----- Original Message -----
From: "Tom Deprez" <zifnabbe@...>
To: <IBObjects@yahoogroups.com>
Sent: Sunday, December 09, 2001 10:11 AM
Subject: [IBO] TIBOStoredProc still working correctly?


> Hi,
>
> I see that I was sparse with the code I use, so here's more information.
But, know that this once worked without a problem.
> I'm using version 4.2fn.
>
> Ok, here comes an example how I use a stored proc and which gives me such
a strange error (first time called it gives me the message 'ERROR Creating
Cursor Handle', then it does it's job like a charm)
> This error just came up and it might be caused by 2 things (haven't
checked the SP's in between): 1. I recreated my database, but I just did an
extract DDL and recreated it with that output, so I don't think the error
has to do with this. 2. I upgraded to 4.2fn
>
> Here is one of the queries:
>
> BEGIN
> SELECT PLANDATA_STARTTIME, PLANDATA_ENDTIME, PLANDATA_AMOUNT
> FROM PLANDATA
> WHERE PLANDATA_DAYNUMBER = :DAYNUMBER
> AND SERVICE_ID = :SERVICEID
> AND PLANDATA_ENDTIME >= :PROPOSEDDATETIME
> AND PLANDATA_STARTTIME >= :PROPOSEDDATETIME
> INTO STARTTIMESLOT, ENDTIMESLOT, AMOUNT;
> SUSPEND;
> END
>
> SERVICEID = integer; DAYNUMBER = SmallInt; PROPOSEDDATETIME = Time
> STARTTIMESLOT, ENDTIMESLOT = TimeStamp; AMOUNT = integer.
>
> I call it with a TIBOStoredProc in the following way:
>
> with dbData.spGetTimeSlot do begin
> Params.ParamValues['SERVICEID'] := ServiceID;
> Params.ParamValues['DAYNUMBER'] := DayOfWeek(ProposedDateTime);
> Params.ParamValues['PROPOSEDDATETIM'] := ProposedDateTime;
> Prepare;
> ExecSQL;
> AppAmount := Params.ParamValues['AMOUNT'];
> ...
> end;
>
> The Error happes at the Prepare statement.
>
> Another example:
>
> BEGIN
> SELECT MAX(APP_STARTDATETIME) FROM APPOINTMENTS
> WHERE PERSON_ID = :PERSONID
> INTO :LAST_APPOINTMENT;
> SELECT SERVICE_ID FROM APPOINTMENTS
> WHERE PERSON_ID = :PERSONID
> AND APP_STARTDATETIME = :LAST_APPOINTMENT
> INTO :LAST_SERVICEID;
> END
>
>
> with dbData.spGetLastAppointment do begin
> Params.ParamValues['PERSONID'] := PersonID;
> Prepare;
> ExecSQL;
> ...
> end;