I solved this problemn creating VIEW with this SQL
Code: Select all
CREATE VIEW vw_solicitacao_funcionario AS
(
select sf.id, sf.funcao, sf.solicitante, sf.motivo, sf.autorizacao, c.cargo, f.nome, m.motivo as motivo_nome, sf.situacao, sf.data_solicitacao, sf.prioridade, sf.anotacoes, sf.data_autorizacao, fs.nome as autorizacao_nome
from solicitacao_funcionario sf
left join cargo c on c.codigo=sf.funcao
left join usuario u on u.funcionario=sf.solicitante
left join funcionario f on f.id=u.funcionario
left join motivo m on m.codigo=sf.motivo
left join usuario us on us.funcionario=sf.autorizacao
left join funcionario fs on fs.id=us.funcionario
order by sf.id asc
)
First, i use Generate SQL, but in the TMyQuery.SQLRefresh, I insert this view. It's works.
But i use this in other table, and now, show the same error:
Steps:
1) I insert the SQL
Code: Select all
select fs.*, m.motivo as motivo_nome
from funcionario_salario fs
left join motivo m on m.codigo = fs.motivo
order by fs.data_salario asc
2) Execute and Generate SQL
3) Create VIEW
Code: Select all
CREATE VIEW vw_funcionario_salario as
(
select fs.*, m.motivo as motivo_nome
from funcionario_salario fs
left join motivo m on m.codigo = fs.motivo
order by fs.data_salario asc
)
4) Put this VIEW in the TMyQuery.SQLRefresh
Code: Select all
select * from vw_funcionario_salario
where
id = :id
I have others tableas with the same steps, and it works.
The error show when i use Insert(TMyQuery.Append and after TMyQuery.Post).
If i use Update(TMyQuery.Edit and after TMyQuery.Post), don't show the error.
*I Use Auto Increment in column, in MySQL DB.
If in event AfterPost, i insert:
Code: Select all
procedure TdmFuncionarios.qrSalarioAfterPost(DataSet: TDataSet);
begin
DataSet.Refresh;
end;
It works, but i don't want refresh Dataset, I want refresh the Record.