serial field with delphi
Posted in 1999
Topics: General Discussion
anyone know how to get the new serial field created by informix in a
"insert
" request ?
ex : query.sql :
insert into table (code,libelle) values (:code,:libelle)
code is serial(4) and libelle is string
program :
Query.ParamByName('libelle').AsString := 'toto';
Query.ExecSql;
I want to know what is the value of "code" in the row generated.
For the moment, i use "append" in a "select" request and i can get the
serial after the "post",
but if it is possible to use "insert", it will be better
Thanks for your time.
JM
Hi JM!
This sample code have been tested on Delphi 3.0+BDE+Infrormix Native Driver
uses ...., BDE;
........
type
TSQLCA =
record
sqlcode : longint;
sqlerrm : array[1..72] of char; { error message parameters }
sqlerrp : array[1..8] of char;
sqlerrd : array[1..6] of Integer;
{ 1 - estimated number of rows returned }
{ 2 - serial value after insert or ISAM error code }
^^^^^^^^^^^^^^^^^^^^^^^^^^
{ 3 - number of rows processed }
{ 4 - estimated cost }
{ 5 - offset of the error into the SQL statement }
{ 6 - rowid after insert }
sqlwarn : record
sqlwarn1 : char; { = W if any of sqlwarn[1-7] = W }
sqlwarn2 : char; { = W if any truncation occurred or
database has transactions }
sqlwarn3 : char; { = W if a null value returned or
ANSI database }
sqlwarn4 : char; { = W if no. in select list != no. in into list or
turbo backend }
sqlwarn5 : char; { = W if no where clause on prepared update,
delete or incompatible float format }
sqlwarn6 : char; { = W if non-ANSI statement }
sqlwarn7 : char; { reserved }
sqlwarn8 : char; { reserved }
end;
end;
......
function GetSQLCA(DataBase : TDataBase) : TSQLCA;
var i : word;
FSQLCA : TSQLCA;
begin
DbiGetProp(hDBIObj(DataBase.Handle),
drvNATIVESQLCA,
@FSQLCA,
sizeof(TSQLCA),
i);
Result := FSQLCA;
end;
anyone know how to get the new serial field created by informix in a
> "insert
> " request ?
>
> ex : query.sql :
> insert into table (code,libelle) values (:code,:libelle)
> code is serial(4) and libelle is string>
> program :
> Query.ParamByName('libelle').AsString := 'toto';
> Query.ExecSql;
>
> I want to know what is the value of "code" in the row generated.
>
> For the moment, i use "append" in a "select" request and i can get the
> serial after the "post",
> but if it is possible to use "insert", it will be better
>
> Thanks for your time.
>
> JM
uses ...., BDE;
type
TSQLCA =
record
sqlcode : longint;
sqlerrm : array[1..72] of char; { error message parameters }
sqlerrp : array[1..8] of char;
sqlerrd : array[1..6] of Integer;
{ 1 - estimated number of rows returned }
{ 2 - serial value after insert or ISAM error code }
^^^^^^^^^^^^^^^^^^^^^^^^^^
{ 3 - number of rows processed }
{ 4 - estimated cost }
{ 5 - offset of the error into the SQL statement }
{ 6 - rowid after insert }
sqlwarn : record
sqlwarn1 : char; { = W if any of sqlwarn[1-7] = W }
sqlwarn2 : char; { = W if any truncation occurred or
database has transactions }
sqlwarn3 : char; { = W if a null value returned or
ANSI database }
sqlwarn4 : char; { = W if no. in select list != no. in into list or
turbo backend }
sqlwarn5 : char; { = W if no where clause on prepared update,
delete or incompatible float format }
sqlwarn6 : char; { = W if non-ANSI statement }
sqlwarn7 : char; { reserved }
sqlwarn8 : char; { reserved }
end;
end;
......
function GetSQLCA(DataBase : TDataBase) : TSQLCA;
var i : word;
FSQLCA : TSQLCA;
begin
DbiGetProp(hDBIObj(DataBase.Handle),
drvNATIVESQLCA,
@FSQLCA,
sizeof(TSQLCA),
i);
Result := FSQLCA;
end;