方法一:使用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));
本文详细介绍了使用UniQuery和UniStoredProc方法进行SQL操作的步骤,包括插入、查询和显示最后插入ID的过程。适用于数据库管理与编程初学者。
1212

被折叠的 条评论
为什么被折叠?



