• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Delphi开发中增删改查操作以及存储过程的调用方式

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

1、SQL实现增删改

try
          if not DTM.Conn.InTransaction then
            DTM.Conn.StartTransaction;
          //插入制式机型
          Init;
          A('insert into scd2_det2(scd22_flow, scd22_fmt, scd22_price_up, scd22_rmks, scd22_crt_by, scd22_crt_date, scd22_mod_times, scd22_mod_by, scd22_mod_date, ');
          A('    scd22_char1, scd22_char2, scd22_char3, scd22_char4, scd22_char5, scd22_char6, scd22_qty1, scd22_qty2) ');
          A('select :sc2_flow, scd22_fmt, scd22_price_up, scd22_rmks, :curr_user, sysdate, 0, :curr_user, sysdate, ');
          A('    scd22_char1, scd22_char2, scd22_char3, scd22_char4, scd22_char5, scd22_char6, scd22_qty1, scd22_qty2 ');
          A('from scd2_det2 ');
          A('where scd22_flow = :org_sc2_flow ');
          P('sc2_flow').Value := sc2_mstr.F('sc2_flow').Value;
          P('org_sc2_flow').Value := sc2_flow;
          P('curr_user').Value := g_UserInfo.UserID;
          ExecSQL;

          //插入明细机型
          Init;
          A('insert into scd2_det(scd2_flow, scd2_mt, scd2_price_down, scd2_rmks, scd2_crt_by, scd2_crt_date, scd2_mod_times, scd2_mod_by, scd2_mod_date, ');
          A('    scd2_char1, scd2_char2, scd2_char3, scd2_char4, scd2_char5, scd2_char6, scd2_qty1, scd2_qty2, SCD2_BASE) ');
          A('select :sc2_flow, scd2_mt, scd2_price_down, scd2_rmks, :curr_user, sysdate, 0, :curr_user, sysdate, ');
          A('    scd2_char1, scd2_char2, scd2_char3, scd2_char4, scd2_char5, scd2_char6, scd2_qty1, scd2_qty2, SCD2_BASE ');
          A('from scd2_det ');
          A('where scd2_flow = :org_sc2_flow ');
          P('sc2_flow').Value := sc2_mstr.F('sc2_flow').Value;
          P('org_sc2_flow').Value := sc2_flow;
          P('curr_user').Value := g_UserInfo.UserID;
          ExecSQL;
          DTM.Conn.Commit;
        except
          if DTM.Conn.InTransaction then
            DTM.Conn.Rollback;
          Raise;
          abort;
        end;

        if PageMain.ActivePage=Page1 then
        begin
          scd2_det2.Close;
          scd2_det2.Open;
          scd2_det.Close;
          scd2_det.Open;
        end;



with Query do
     begin
        init;
        A('update equ_mstr set equ_examin_date  = trunc(:equ_examin_date,''DD''),    ');
        A('   equ_next_date = trunc(:equ_examin_date,''DD'') +  equ_interval  where equ_part_id = :equ_part_id ') ;
        P('equ_part_id').AsString  := equd_det.F('equd_part_id').AsString;
        P('equ_examin_date').Asdatetime :=  equd_det.F('equd_date').Asdatetime;
        try
          if not DTM.Conn.InTransaction then
            DTM.Conn.StartTransaction;
            ExecSQL;
          DTM.Conn.Commit;
         except
           if DTM.Conn.InTransaction then
             DTM.Conn.Rollback;
           Raise;
         end;
      end;
     equ_mstr.RefreshCurrent;
end;

 

2、执行存储过程

with FSPUIQA4_qty do
  begin
    try
      if not DTM.Conn.InTransaction then
        DTM.Conn.StartTransaction;
      ExecProc;
      DTM.Conn.Commit;
    except
      if DTM.Conn.InTransaction then
        DTM.Conn.Rollback;
      Raise;
      abort;
    end;
  end;

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap