方法一:使用UniQuery
UniQuery. SQL.Clear;
UniQuery. SQL.Add (' INSERT INTO kvartal_prem.tReports (name, remark, report, dotmatrix) ');
UniQuery. SQL.Add (' SELECT name, remark, report, dotmatrix from kvartal_prem.tReports');
UniQuery. SQL.Add (' WHERE id =:id ');
UniQuery. ParamByName (' id ').AsInteger: = id;
UniQuery. Execute;
ShowMessage (IntToStr (UniQuery. LastInsertId));
方法二:使用UniStoredProc
UniStoredProc. StoredProcName: = ' InstReports';
UniStoredProc. PrepareSQL;
UniStoredProc. ParamByName (' pid ').AsInteger: = id;
UniStoredProc. Execute;
ShowMessage (IntToStr (UniStoredProc. ParamByName (' poutid ').AsInteger));