const Dialect = 3;
var TypeItem : Char;
Statement_Length : integer;
StatementBuffer :
array [0..7]
of Char;
StatementTyp : integer;
i : integer;
XSQLVar : PXSQLVAR;
ListItem : TListItem;
SQL : PCHAR;
Begin
SQL := '
SELECT * FROM TESTUNG';
GetMem(Out_SQLDA, XSQLDA_LENGTH(0));
FillChar(Out_SQLDA^, XSQLDA_LENGTH(0), 0);
OUT_SQLDA.sqln := 0;
Out_SQLDA.sqld := 0;
Out_SQLDA.version := SQLDA_VERSION1;
// Wert = 1
isc_dsql_alloc_statement2(@STATUS_VECTOR,@DBHandle,@STMT_Handle);
isc_dsql_prepare(@Status_Vector, @Tran_Handle, @Stmt_Handle, 0,
SQL, Dialect,
NIL);
TypeItem := Char(isc_info_sql_stmt_type);
isc_dsql_sql_info(@Status_Vector, @Stmt_Handle, 1, @TypeItem, SizeOf(StatementBuffer), StatementBuffer);
if StatementBuffer[0] = Char(isc_info_sql_stmt_type)
then
begin
Statement_Length := isc_vax_integer(@StatementBuffer[1], 2);
StatementTyp := isc_vax_integer(@StatementBuffer[3], Statement_Length);
end;
isc_dsql_describe(@Status_Vector, @Stmt_Handle, Dialect, Out_SQLDA);
if out_SQLda^.sqld > out_SQLda^.sqln
then
begin
IbReAlloc(Out_SQLDA, XSQLDA_LENGTH(Out_SQLDA.sqln), XSQLDA_LENGTH(OUT_SQLDA.sqld));
Out_SQLDA.sqln := Out_SQLDA.sqld;
isc_dsql_describe(@STATUS_VECTOR,@Stmt_Handle,Dialect,out_SQLda);
end;
{$R-}
for i := 0
to Out_SQLDA.sqld - 1
do
begin
XSQLVar := @Out_SQLDA.SqlVar[i];
case XSQLVar.sqltype
and (
not 1)
of
SQL_BOOLEAN, SQL_TEXT, SQL_TYPE_DATE, SQL_TYPE_TIME, SQL_DATE,
SQL_BLOB, SQL_ARRAY, SQL_QUAD, SQL_SHORT,
SQL_LONG, SQL_INT64, SQL_DOUBLE, SQL_FLOAT, SQL_D_FLOAT:
if XSqlVar.sqllen = 0
then IbReAlloc(XSqlVar.sqldata, 0, 1)
else IbReAlloc(XSqlVar.sqldata, 0, XSqlVar.sqllen)
SQL_VARYING: IbReAlloc(XSqlVar.sqldata, 0, XSqlVar.sqllen + 2)
end;
if (XSqlVar.sqltype
and 1) <> 0
then ReallocMem(XSqlVar.sqlind, SizeOf(Short))
else XSqlVar.sqlind :=
nil;
end;
{$IFOPT D+}
{$R+}
{$ENDIF}
isc_dsql_execute(@Status_Vector, @Tran_Handle, @Stmt_Handle, Dialect,
NIL);
while isc_dsql_fetch(@Status_Vector, @Stmt_Handle, Dialect, Out_SQLDA) = 0
Do
Begin
for i := 0
to Out_SQLDA.sqld
do
begin
XSqlVar := @Out_SQLDA.sqlvar[i];
...
End;
Procedure IbReAlloc(
var P; OldSize, NewSize: Integer);
Begin
ReallocMem(Pointer(P), NewSize);
if NewSize > OldSize
then
Fillchar((Pchar(P) + OldSize)^, NewSize - OldSize, #0);
End;