Subject RE: [IBO] Invalid Transaction Handle
Author Gerhardus Geldenhuis
> Is "Invalid transaction handle" the only error? If so, don't look at the
> data assignments, they are not causing this error.

Yes
This is the exact error I get.(When I run the executable)

ISC ERROR CODE:335544332

ISC ERROR MESSAGE:
invalid transaction handle (expecting explicit transaction start)

STATEMENT:
TIBOInternalDataset:
"<TApplication>.Form1.IBOStoredProc2.IBOqrIBOStoredProc2." stHandle=13784644
(ERROR)

I get the following error while running the program through Delphi.

Project Project1.exe raised exception class EIBO_ISCError with message 'ISC
ERROR CODE:335544327

ISC ERROR MESSAGE:
invalid request handle

STATEMENT:
IBOInternalDataset:
"<TApplication>.Form1.IBOStoredProc1.IBOqrIBOStoredProc1."stHandle=13785068(
ERROR)

>
> A transaction handle is passed back to the client when the client library
> successfully starts a transaction on the server on behalf of the
> application. It gets a unique new transaction handle each time your
> application's transaction object starts a new transaction
> (CommitRetaining
> aside; which effectively "restarts" the same transaction).

I dont do a commit retaining. I'l give my form properties at the bottom of
the screen.

>
> If your transaction object (which will be SPDiary.IB_Transaction)
> committed
> or rolled back, then the transaction handle becomes
> invalid.

I actually dont need to commit or rollback because it is a select
procedure. I only need the result set.

> Alternatively, if no transaction was started, then there is no
> transaction handle and the client library might attempt to pass Null as a
> transaction handle - that's not valid either.
>
> So, you'll need to test for the presence of a *physical* transaction
> handle. The property for this is InTransaction:
>

I tested this and the first time I execute the code both if's are
false and gets executed. If I excute it again only the second
if statement(Prepare) is executed.

if not IB_Transaction.InTransaction then
IB_Transaction.StartTransaction;
if not Prepared then
Prepare;
>
> Without so little info on what you are doing, this is at best a guess in
> the absence of missing symptoms...such as the transaction handle
> DOES exist
> but has unhandled exceptions somewhere...in which case, the
> suggested code
> above will continue to throw errors.

My guess is unhandled exceptions but I frankly have no idea.
I have tried to include much more helpfull information.
I dont no what is causing exceptions.

Here is the code of the procedure I am calling. Doing a select in Interbase
Workbench
from this procedure returns the desired result.

CREATE PROCEDURE FILTER_DIARY (IN_DATE Date, IN_USER VarChar(15)) returns
(OUT_DATE Date, OUT_DEPARTMENT VarChar(30), OUT_DARNO_RONO VarChar(15),
OUT_SCREENNAME VarChar(30), OUT_PRC Integer, OUT_JOBDESCRIPTION
VarChar(100), OUT_DATECOMPLETED Date) AS
BEGIN
select
diary_date,
department,
darno_rono,
screenname,
productionreworkcycle,
jobdescription,
datecompleted
from diary
where screenname in (select screenname from useraccess where username =
:in_user)and
datecompleted is null and
diary_date = :in_date
into
:out_date,
:out_department,
:out_darno_rono,
:out_screenname,
:out_prc,
:out_jobdescription,
:out_datecompleted;
/*
I had a SUSPEND clause here and tried it with and without.
*/

END

Here is the properties of all my components.

object IBOStoredProc1: TIBOStoredProc
Params = <>
StoredProcHasDML = False
StoredProcName = 'FILTER_DIARY'
DatabaseName = 'C:\LocalDB\BodyTrak2.gdb'
IB_Connection = IB_Connection1
IB_Transaction = IB_Transaction1
end
object IB_Connection1: TIB_Connection
PasswordStorage = psNotSecure
SQLDialect = 3
Params.Strings = (
'PATH=C:\LocalDB\BodyTrak2.gdb'
'SQL DIALECT=3'
'USER NAME=sysdba')
SavedPassword = '.JuMbLe.01.432B0639073E0E4B49'
end
object IB_Transaction1: TIB_Transaction
IB_Connection = IB_Connection1
AutoCommit = True
Isolation = tiConcurrency
end
object DataSource1: TDataSource
DataSet = IBOStoredProc1
end

I have set the Transaction components ib_connection property to the
connection
but I have not set the default transaction of the ib_connection. I dont
realy know what the difference is if you set the default transaction of the
ib_connection or if you set the ib_connection property of the transaction.
You cant do both it gives exceptions.

Here is the code I run:
IB_MonitorDialog1.Show;
with IBOStoredProc1 do
begin
if not IB_Transaction.InTransaction then
IB_Transaction.StartTransaction;
if not Prepared then
Prepare;
ParamByName('IN_DATE').AsDate:=Today+3;
ParamByName('IN_USER').AsString:='TALETTADEV';
try
Open;
except
end;//try except
end;//with do

It gives an error on the Open Statement. Here is the error and the complete
monitor text:
(I removed the ----*/ strings)

Project Project1.exe raised exception class EIBO_ISCError with message 'ISC
ERROR CODE:335544327
ISC ERROR MESSAGE:
invalid request handle
STATEMENT:
IBOInternalDataset:
"<TApplication>.Form1.IBOStoredProc1.IBOqrIBOStoredProc1."stHandle=13785068(
ERROR)


CONNECT DATABASE C:\LocalDB\BodyTrak2.gdb
DB_HANDLE = 13785264

SECONDS = 1.021
DATABASE INFO
DB_HANDLE = 13785264
START TRANSACTION
DB HANDLE COUNT 1
TR_HANDLE = 13784996
START TRANSACTION
DB HANDLE COUNT 1
TR_HANDLE = 13784760
PREPARE STATEMENT
TR_HANDLE = 13784760
STMT_HANDLE = 13784832

SELECT RDB$PARAMETER_NAME
FROM RDB$PROCEDURE_PARAMETERS
WHERE RDB$PARAMETER_TYPE = ? /* RDB$PARAMETER_TYPE */
AND RDB$PROCEDURE_NAME = ? /* RDB$PROCEDURE_NAME */
ORDER BY RDB$PARAMETER_NUMBER ASC

PLAN SORT ((RDB$PROCEDURE_PARAMETERS INDEX (RDB$INDEX_18)))

FIELDS = [ Version 1 SQLd 1 SQLn 30
RDB$PROCEDURE_PARAMETERS.RDB$PARAMETER_NAME = <NIL> ]
EXECUTE STATEMENT
TR_HANDLE = 13784760
STMT_HANDLE = 13784832
PARAMS = [ Version 1 SQLd 2 SQLn 2
[RDB$PARAMETER_TYPE] = 0
[RDB$PROCEDURE_NAME] = 'FILTER_DIARY ' ]
EXECUTE STATEMENT
TR_HANDLE = 13784760
STMT_HANDLE = 13784832
PARAMS = [ Version 1 SQLd 2 SQLn 2
[RDB$PARAMETER_TYPE] = 1
[RDB$PROCEDURE_NAME] = 'FILTER_DIARY ' ]
PREPARE STATEMENT
TR_HANDLE = 13784996
STMT_HANDLE = 13785068

EXECUTE PROCEDURE FILTER_DIARY
? /* IN_DATE */ ,
? /* IN_USER */

FIELDS = [ Version 1 SQLd 7 SQLn 30
FILTER_DIARY.OUT_DATE = <NIL>
FILTER_DIARY.OUT_DEPARTMENT = <NIL>
FILTER_DIARY.OUT_DARNO_RONO = <NIL>
FILTER_DIARY.OUT_SCREENNAME = <NIL>
FILTER_DIARY.OUT_PRC = <NIL>
FILTER_DIARY.OUT_JOBDESCRIPTION = <NIL>
FILTER_DIARY.OUT_DATECOMPLETED = <NIL> ]
PREPARE STATEMENT
TR_HANDLE = 13784760
STMT_HANDLE = 13779192

SELECT R.RDB$FIELD_NAME
, R.RDB$RELATION_NAME
FROM RDB$RELATION_FIELDS R, RDB$FIELDS F
WHERE R.RDB$FIELD_SOURCE = F.RDB$FIELD_NAME
AND F.RDB$COMPUTED_SOURCE IS NOT NULL
AND NOT R.RDB$RELATION_NAME STARTING WITH 'RDB$'
ORDER BY 1 ASC

PLAN SORT (JOIN (F NATURAL,R INDEX (RDB$INDEX_3)))

FIELDS = [ Version 1 SQLd 2 SQLn 30
RDB$RELATION_FIELDS.RDB$FIELD_NAME = <NIL>
RDB$RELATION_FIELDS.RDB$RELATION_NAME = <NIL> ]
EXECUTE STATEMENT
TR_HANDLE = 13784760
STMT_HANDLE = 13779192
PARAMS = [ ]
EXECUTE2 DSQL
TR_HANDLE = 13784996
STMT_HANDLE = 13785068
PARAMS = [ Version 1 SQLd 2 SQLn 2
[IN_DATE] = '11 Aug 2002'
[IN_USER] = 'TALETTADEV' ]
FIELDS = [ Version 1 SQLd 7 SQLn 7
FILTER_DIARY.OUT_DATE = <NULL>
FILTER_DIARY.OUT_DEPARTMENT = <NULL>
FILTER_DIARY.OUT_DARNO_RONO = <NULL>
FILTER_DIARY.OUT_SCREENNAME = <NULL>
FILTER_DIARY.OUT_PRC = <NULL>
FILTER_DIARY.OUT_JOBDESCRIPTION = <NULL>
FILTER_DIARY.OUT_DATECOMPLETED = <NULL> ]

SECONDS = 0.040
INTERPRETE BUFFER =

ERRCODE = 22
INTERPRETE BUFFER = invalid request handle

ERRCODE = -1

Groete
Gerhardus