Fórum campo auto incremento - SQLConnection.Execute - deprecated #425804
09/10/2012
0
function Execute(const SQL: string; Params: TParams): Integer; overload;
function Execute(const SQL: string; Params: TParams; var ResultSet: TDataSet): Integer; overload;
function Execute(const SQL: string; Params: TParams; ResultSet: Pointer): Integer; overload; deprecated 'Use overloaded method instead';
procedure TDMCustomer.cds_customerNewRecord(DataSet: TDataSet);
var
ResultSet: TCustomSQLDataSet;
SQLstmt: string;
begin
SQLstmt := 'SELECT gen_id(GCUSTOMER,1)' + 'as VALOR from RDB$DATABASE;';
ResultSet := nil;
try
DMCustomer.SQLConnection.Execute(SQLstmt, nil, @ResultSet);
if Assigned(ResultSet) then
begin
cds_customer.FieldByName('CUSTOMERID').AsInteger :=
ResultSet.FieldByName('VALOR').AsInteger;
end;
finally
ResultSet.Free;
end;
end;
O campo CUSTOMERID não recebe o valor de ResultSet! Porque? Por Favor podem me ajudar uma outra maneira?
Celso Saito
Curtir tópico
+ 0Posts
09/10/2012
Marco Salles
Me parece que sua instrução sql esta errada
SQLstmt := 'SELECT gen_id(GCUSTOMER,1)' + 'as VALOR from RDB$DATABASE;';
por
SQLstmt := 'SELECT gen_id(GCUSTOMER,1) AS VALOR from RDB$DATABASE';
Verifique também o nome do Gerador se esta com a sintaxi correta
[]sds
Gostei + 0
09/10/2012
Celso Saito
Me parece que sua instrução sql esta errada
SQLstmt := 'SELECT gen_id(GCUSTOMER,1)' + 'as VALOR from RDB$DATABASE;';
por
SQLstmt := 'SELECT gen_id(GCUSTOMER,1) AS VALOR from RDB$DATABASE';
Verifique também o nome do Gerador se esta com a sintaxi correta
[]sds
Oi fiz as correções, mas ainda o CUSTOMERID não consegue pegar o VALOR.
Gostei + 0
09/10/2012
Celso Saito
Me parece que sua instrução sql esta errada
SQLstmt := 'SELECT gen_id(GCUSTOMER,1)' + 'as VALOR from RDB$DATABASE;';
por
SQLstmt := 'SELECT gen_id(GCUSTOMER,1) AS VALOR from RDB$DATABASE';
Verifique também o nome do Gerador se esta com a sintaxi correta
[]sds
Oi fiz as correções, mas ainda o CUSTOMERID não consegue pegar o VALOR.
assim ficou...
procedure TDMCustomer.cds_customerNewRecord(DataSet: TDataSet);
var
ResultSet: TCustomSQLDataSet;
SQLstmt: string;
begin
ResultSet := nil;
SQLstmt := 'SELECT gen_id(GCUSTOMER,1) AS VALOR from RDB$DATABASE';
try
DMCustomer.SQLConnection.Execute(SQLstmt, nil, @ResultSet);
if Assigned(ResultSet) then
begin
cds_customer.FieldByName('CUSTOMERID').AsInteger := ResultSet.FieldByName('VALOR').AsInteger;
end;
finally
ResultSet.Free;
end;
end;
Gostei + 0
09/10/2012
Marco Salles
Não entendi ??? Assim ficou certo ou assim continua dando erro ???
Gostei + 0
09/10/2012
Celso Saito
Não entendi ??? Assim ficou certo ou assim continua dando erro ???
oi, desculpe... continua dando erro.
Gostei + 0
09/10/2012
Celso Saito
Não entendi ??? Assim ficou certo ou assim continua dando erro ???
oi, desculpe... continua dando erro.
executei essa sql e está ok - SELECT gen_id(GCUSTOMER,1) AS VALOR from RDB$DATABASE
parece mesmo que a causa está aqui -> ou no Execute ou no Assigned
DMCustomer.SQLConnection.Execute(SQLstmt, nil, @ResultSet);
if Assigned(ResultSet) then
Gostei + 0
09/10/2012
Alisson Santos
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)