Page 1 of 1
Problema Recuperar Ultimo ID MSSQL
Posted: Mon 07 Jul 2014 14:49
by decioneto2000
Não consigo recuperar o Ultimo ID inserido no MSSQL com cached updata abilitado e campo id autoincremento usando master detail alguem ja conseguiu algo?
Thanks;
Decio
Re: Problema Recuperar Ultimo ID MSSQL
Posted: Wed 09 Jul 2014 11:33
by Pinturiccio
Please describe your scenario in more details. Please provide the following information:
1. DDL/DML scripts of the tables you use;
2. The sample of code that causes the issue. A test project will be appreciated. You can send us a test project by using the contact form on our website
http://www.devart.com/company/contactform.html
3. Which behavior do you get?
4. Which behavior do you expect?
Re: Problema Recuperar Ultimo ID MSSQL
Posted: Thu 10 Jul 2014 15:15
by decioneto2000
Usando Uniquery Delphi 7 MSSQL 2012 uma simples select em uma tabela configurando os insert e update ligada a uma master detail porem quando se aplica o apply nao consigo retornoa ro id identity deo MSSQL
gratos
Re: Problema Recuperar Ultimo ID MSSQL
Posted: Wed 16 Jul 2014 15:12
by azyk
If you are using your own INSERT SQL query in the dataset, then to retrieve the inserted record ID, you should :
- set TUniQuery.Options.ReturnParams to True
- in the TUniQuery.BeforeUpdateExecute event specify explicitly the ptInputOutput parameter type for the Identity field
For example:
Code: Select all
DetailUniQuery.Options.ReturnParams := True;
...
procedure TForm1.DetailUniQueryBeforeUpdateExecute(Sender: TDataSet;
StatementTypes: TStatementTypes; Params: TDAParams);
begin
if StatementTypes = [stInsert] then
Params.ParamByName('ID').ParamType := ptInputOutput;
end;
Re: Problema Recuperar Ultimo ID MSSQL
Posted: Wed 18 Apr 2018 18:45
by decioneto2000
Esse procedimento funciona com cached Update ativo?
]
Obrigado
Re: Problema Recuperar Ultimo ID MSSQL
Posted: Thu 19 Apr 2018 14:46
by Stellar
The above sample is just for updating the value of an auto-incremental or calculated field in dataset when using cached data updates.