Page 1 of 1

Returning ID on TIBCQuery

Posted: Thu 13 Feb 2014 12:37
by wesleybobato
Hello Friends TIBCQuery fails to capture the ID in the insert ?

begin
 with the TblSQL
  begin
   if Active then
    Close ;
   
  Sql.Clear ;
  SQL.Add ( ' insert into PDV_TURNOS ( TURNO_ID , ' +
                                         ' TURNO_DATA ' +
                                         ' TURNO_HORA ' +
                                         ' TURNO_CAIXA ' +
                                         ' TURNO_OPERADOR ) ' +
                                         ' Values ​​( : TURNO_ID , ' +
                                         ': TURNO_DATA ' +
                                         ': TURNO_HORA ' +
                                         ': TURNO_CAIXA ' +
                                         ': TURNO_OPERADOR ) ' +
                                         ' Returning TURNO_ID ' ) ;
   Options.ReturnParams : = True ;
   ParamCheck : = True ;
   KeyGenerator : = ' GEN_PDV_TURNOS_ID ' ;
   KeyFields : = ' TURNO_ID ';
   Params [ 1 ] AsDateTime : = Date ; .
   Params [ 2 ] AsDateTime : = Time ; .
   Params [ 3 ] As Integer : = 2 ; .
   Params [ 4 ] As Integer : = 1 ; .

   ExecSQL ;
   ShowMessage ( ParamByName ( ' TURNO_ID ' ) AsString . ) ; // not Work...
  end ;
end ;

In FibPlusQuery, FiredacQuery and SQLQuery Works Only IBDAC they can not help me.

Re: Returning ID on TIBCQuery

Posted: Tue 18 Feb 2014 11:20
by PavloP
For the fields, that are specified after RETURNING, there are automatically generated output parameters with the RET_ prefix.
This is described in the documentation:
http://www.devart.com/ibdac/docs/index. ... ataset.htm

In your example you should use

Code: Select all

ShowMessage(ParamByName('RET_TURNO_ID').AsString);
instead of

Code: Select all

ShowMessage(ParamByName('TURNO_ID').AsString);