|
@@ -20,8 +20,8 @@ type
|
|
protected
|
|
protected
|
|
Status : array [0..19] of ISC_STATUS;
|
|
Status : array [0..19] of ISC_STATUS;
|
|
Statement : pointer;
|
|
Statement : pointer;
|
|
- FFieldFlag : array of shortint;
|
|
|
|
- FinFieldFlag : array of shortint;
|
|
|
|
|
|
+ FFieldFlag : PByte;
|
|
|
|
+ FinFieldFlag : PByte;
|
|
SQLDA : PXSQLDA;
|
|
SQLDA : PXSQLDA;
|
|
in_SQLDA : PXSQLDA;
|
|
in_SQLDA : PXSQLDA;
|
|
ParamBinding : array of integer;
|
|
ParamBinding : array of integer;
|
|
@@ -59,8 +59,8 @@ type
|
|
Procedure DeAllocateCursorHandle(var cursor : TSQLCursor); override;
|
|
Procedure DeAllocateCursorHandle(var cursor : TSQLCursor); override;
|
|
Function AllocateTransactionHandle : TSQLHandle; override;
|
|
Function AllocateTransactionHandle : TSQLHandle; override;
|
|
|
|
|
|
- procedure CloseStatement(cursor : TSQLCursor); override;
|
|
|
|
procedure PrepareStatement(cursor: TSQLCursor;ATransaction : TSQLTransaction;buf : string; AParams : TParams); override;
|
|
procedure PrepareStatement(cursor: TSQLCursor;ATransaction : TSQLTransaction;buf : string; AParams : TParams); override;
|
|
|
|
+ procedure UnPrepareStatement(cursor : TSQLCursor); override;
|
|
procedure FreeFldBuffers(cursor : TSQLCursor); override;
|
|
procedure FreeFldBuffers(cursor : TSQLCursor); override;
|
|
procedure Execute(cursor: TSQLCursor;atransaction:tSQLtransaction; AParams : TParams); override;
|
|
procedure Execute(cursor: TSQLCursor;atransaction:tSQLtransaction; AParams : TParams); override;
|
|
procedure AddFieldDefs(cursor: TSQLCursor;FieldDefs : TfieldDefs); override;
|
|
procedure AddFieldDefs(cursor: TSQLCursor;FieldDefs : TfieldDefs); override;
|
|
@@ -389,6 +389,7 @@ begin
|
|
curs := TIBCursor.create;
|
|
curs := TIBCursor.create;
|
|
curs.sqlda := nil;
|
|
curs.sqlda := nil;
|
|
curs.statement := nil;
|
|
curs.statement := nil;
|
|
|
|
+ curs.FPrepared := False;
|
|
AllocSQLDA(curs.SQLDA,1);
|
|
AllocSQLDA(curs.SQLDA,1);
|
|
AllocSQLDA(curs.in_SQLDA,1);
|
|
AllocSQLDA(curs.in_SQLDA,1);
|
|
result := curs;
|
|
result := curs;
|
|
@@ -401,6 +402,8 @@ begin
|
|
begin
|
|
begin
|
|
reAllocMem(SQLDA,0);
|
|
reAllocMem(SQLDA,0);
|
|
reAllocMem(in_SQLDA,0);
|
|
reAllocMem(in_SQLDA,0);
|
|
|
|
+ reAllocMem(FFieldFlag,0);
|
|
|
|
+ reAllocMem(FInFieldFlag,0);
|
|
end;
|
|
end;
|
|
FreeAndNil(cursor);
|
|
FreeAndNil(cursor);
|
|
end;
|
|
end;
|
|
@@ -411,16 +414,6 @@ begin
|
|
result := TIBTrans.create;
|
|
result := TIBTrans.create;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TIBConnection.CloseStatement(cursor : TSQLCursor);
|
|
|
|
-begin
|
|
|
|
- with cursor as TIBcursor do
|
|
|
|
- begin
|
|
|
|
- if isc_dsql_free_statement(@Status, @Statement, DSQL_Drop) <> 0 then
|
|
|
|
- CheckError('FreeStatement', Status);
|
|
|
|
- Statement := nil;
|
|
|
|
- end;
|
|
|
|
-end;
|
|
|
|
-
|
|
|
|
procedure TIBConnection.PrepareStatement(cursor: TSQLCursor;ATransaction : TSQLTransaction;buf : string; AParams : TParams);
|
|
procedure TIBConnection.PrepareStatement(cursor: TSQLCursor;ATransaction : TSQLTransaction;buf : string; AParams : TParams);
|
|
|
|
|
|
var dh : pointer;
|
|
var dh : pointer;
|
|
@@ -430,7 +423,6 @@ var dh : pointer;
|
|
i : integer;
|
|
i : integer;
|
|
|
|
|
|
begin
|
|
begin
|
|
-// ObtainSQLStatementType(cursor,buf);
|
|
|
|
with cursor as TIBcursor do
|
|
with cursor as TIBcursor do
|
|
begin
|
|
begin
|
|
dh := GetHandle;
|
|
dh := GetHandle;
|
|
@@ -463,6 +455,7 @@ begin
|
|
|
|
|
|
if isc_dsql_prepare(@Status, @tr, @Statement, 0, @Buf[1], Dialect, nil) <> 0 then
|
|
if isc_dsql_prepare(@Status, @tr, @Statement, 0, @Buf[1], Dialect, nil) <> 0 then
|
|
CheckError('PrepareStatement', Status);
|
|
CheckError('PrepareStatement', Status);
|
|
|
|
+ FPrepared := True;
|
|
if assigned(AParams) and (AParams.count > 0) then
|
|
if assigned(AParams) and (AParams.count > 0) then
|
|
begin
|
|
begin
|
|
AllocSQLDA(in_SQLDA,Length(ParamBinding));
|
|
AllocSQLDA(in_SQLDA,Length(ParamBinding));
|
|
@@ -471,7 +464,7 @@ begin
|
|
if in_SQLDA^.SQLD > in_SQLDA^.SQLN then
|
|
if in_SQLDA^.SQLD > in_SQLDA^.SQLN then
|
|
DatabaseError(SParameterCountIncorrect,self);
|
|
DatabaseError(SParameterCountIncorrect,self);
|
|
{$R-}
|
|
{$R-}
|
|
- SetLength(FinFieldFlag,in_SQLDA^.SQLD);
|
|
|
|
|
|
+ ReAllocMem(FInFieldFlag,SQLDA^.SQLD+1);
|
|
for x := 0 to in_SQLDA^.SQLD - 1 do with in_SQLDA^.SQLVar[x] do
|
|
for x := 0 to in_SQLDA^.SQLD - 1 do with in_SQLDA^.SQLVar[x] do
|
|
begin
|
|
begin
|
|
if ((SQLType and not 1) = SQL_VARYING) then
|
|
if ((SQLType and not 1) = SQL_VARYING) then
|
|
@@ -484,6 +477,7 @@ begin
|
|
end;
|
|
end;
|
|
if FStatementType = stselect then
|
|
if FStatementType = stselect then
|
|
begin
|
|
begin
|
|
|
|
+ FPrepared := False;
|
|
if isc_dsql_describe(@Status, @Statement, 1, SQLDA) <> 0 then
|
|
if isc_dsql_describe(@Status, @Statement, 1, SQLDA) <> 0 then
|
|
CheckError('PrepareSelect', Status);
|
|
CheckError('PrepareSelect', Status);
|
|
if SQLDA^.SQLD > SQLDA^.SQLN then
|
|
if SQLDA^.SQLD > SQLDA^.SQLN then
|
|
@@ -493,13 +487,15 @@ begin
|
|
CheckError('PrepareSelect', Status);
|
|
CheckError('PrepareSelect', Status);
|
|
end;
|
|
end;
|
|
{$R-}
|
|
{$R-}
|
|
- SetLength(FFieldFlag,SQLDA^.SQLD);
|
|
|
|
|
|
+ ReAllocMem(FFieldFlag,SQLDA^.SQLD+1);
|
|
for x := 0 to SQLDA^.SQLD - 1 do with SQLDA^.SQLVar[x] do
|
|
for x := 0 to SQLDA^.SQLD - 1 do with SQLDA^.SQLVar[x] do
|
|
begin
|
|
begin
|
|
if ((SQLType and not 1) = SQL_VARYING) then
|
|
if ((SQLType and not 1) = SQL_VARYING) then
|
|
SQLData := AllocMem(SQLDA^.SQLVar[x].SQLLen+2)
|
|
SQLData := AllocMem(SQLDA^.SQLVar[x].SQLLen+2)
|
|
|
|
+// ReAllocMem(SQLData,SQLDA^.SQLVar[x].SQLLen+2)
|
|
else
|
|
else
|
|
SQLData := AllocMem(SQLDA^.SQLVar[x].SQLLen);
|
|
SQLData := AllocMem(SQLDA^.SQLVar[x].SQLLen);
|
|
|
|
+// ReAllocMem(SQLData,SQLDA^.SQLVar[x].SQLLen);
|
|
SQLInd := @FFieldFlag[x];
|
|
SQLInd := @FFieldFlag[x];
|
|
end;
|
|
end;
|
|
{$R+}
|
|
{$R+}
|
|
@@ -507,6 +503,18 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+procedure TIBConnection.UnPrepareStatement(cursor : TSQLCursor);
|
|
|
|
+
|
|
|
|
+begin
|
|
|
|
+ with cursor as TIBcursor do
|
|
|
|
+ begin
|
|
|
|
+ if isc_dsql_free_statement(@Status, @Statement, DSQL_Drop) <> 0 then
|
|
|
|
+ CheckError('FreeStatement', Status);
|
|
|
|
+ Statement := nil;
|
|
|
|
+ FPrepared := False;
|
|
|
|
+ end;
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TIBConnection.FreeFldBuffers(cursor : TSQLCursor);
|
|
procedure TIBConnection.FreeFldBuffers(cursor : TSQLCursor);
|
|
var
|
|
var
|
|
x : shortint;
|
|
x : shortint;
|