Purpose: delete a piece of data in the database, and then re-insert the deleted data to another table. At the same time, you need to insert the deletion person and the deletion time in the table.
Run SQL statements
declarev_fwzco t_fwzc_o%rowtype;begin select fwzc_id,zcbm into v_fwzco.fwzc_id,v_fwzco.zcbm from T_FWZC where fwzc_id='56038d65-2a41-4cf7-b136-f2cec915960f'; v_fwzco.BDR :='test'; v_fwzco.BDSJ :='test'; v_fwzco.fwzc_o_id:='dsadas'; insert into t_fwzc_o(fwzc_id,bdr,bdsj,zcbm,fwzc_o_id) values(v_fwzco.fwzc_id,v_fwzco.bdr,v_fwzco.bdsj, v_fwzco.zcbm,v_fwzco.fwzc_o_id); update T_FWZC set jpjd=null where fwzc_id='56038d65-2a41-4cf7-b136-f2cec915960f';end;
Another way of writing: (the above Code may be difficult to make in the database connection string, you can write it in the same way as below .)
VaR sbsql = new stringbuilder (); sbsql. append ("declare"); sbsql. append ("v_fwzco t_fwzc_o % rowtype;"); sbsql. append ("begin"); sbsql. append ("select fwzc_id, zcbm, zcmc, xymc, zccbs, fwcq_id, fwbm, deptcode, deptname, dwjc, ssqy, YZ, JZ, fwsl, JG, MJ, Cs, gjrq, zcsx, dwsx, syzt, jszk, yt, zrr, JD, WD, sfsctpsp, sfzz, CSHR, cssj, BGR, bgrq, BZ, BM, xsydw, jpjd, jpwd, dwsxhz, ssqyhz, zcsxhz, sfzzhz, by1, by2, by3, by4, RQ, sfdtgl, sfdtglhz "); sbsql. append ("into sequence, sequence, v_fwzco.zcmc, v_fwzco.xymc, sequence, v_fwzco.mj, v_fwzco.cs, numeric, v_fwzco.zcsx, "); sbsql. append ("average, minimum, maximum, minimum, maximum, v_fwzco.jd, v_fwzco.wd, maximum, v_fwzco.sfzz, maximum, minimum, maximum, minimum, v_fwzco.bm, minimum, v_fwzco.dwsxhz, v_fwzco.ssqyhz, "); sbsql. append ("begin, v_fwzco.sfzzhz, v_fwzco.by1, v_fwzco.by2, v_fwzco.by3, v_fwzco.by4, v_fwzco.rq, lead, slow"); sbsql. append ("from t_fwzc where zcbm = '{0}';"); sbsql. append ("v_fwzco.bdr: = '{1}';"); sbsql. append ("v_fwzco.bdsj: = '{2}';"); sbsql. append ("v_fwzco.fwzc_o_id: = '{3}';"); sbsql. append ("insert into values (BDR, bdsj, values, fwzc_id, zcbm, zcmc, xymc, zccbs, fwcq_id, fwbm, deptcode, deptname, dwjc, ssqy, YZ, JZ, fwsl, JG, MJ, Cs, gjrq, zcsx, dwsx, syzt, jszk, yt, zrr, JD, WD, sfsctpsp, sfzz, CSHR, cssj, BGR, bgrq, BZ, BM, xsydw, jpjd, jpwd, dwsxhz, ssqyhz, zcsxhz, sfzzhz, by1, by2, by3, by4, RQ, sfdtgl, sfdtglhz) "); sbsql. append ("values (v_fwzco.bdr, expires, v_fwzco.zcmc, v_fwzco.xymc, expires, v_fwzco.dwjc, expires, v_fwzco.jg, v_fwzco.mj, v_fwzco.cs, v_fwzco.gjrq, v_fwzco.zcsx, "); sbsql. append ("average, minimum, maximum, minimum, maximum, v_fwzco.jd, v_fwzco.wd, maximum, v_fwzco.sfzz, maximum, minimum, maximum, minimum, v_fwzco.bm, minimum, v_fwzco.dwsxhz, v_fwzco.ssqyhz, "); sbsql. append ("average, minimum, v_fwzco.by1, v_fwzco.by2, v_fwzco.by3, v_fwzco.by4, v_fwzco.rq, minimum, and maximum);"); sbsql. append ("Update t_fwzc set jpjd = '{4}', jpwd = '{5}', sfdtgl = '{6 }', sfdtglhz = '{7}' Where zcbm = '{8}'; "); sbsql. append ("end;"); SQL = string. format (sbsql. tostring (), zcbm, config. instance. userid, datetime. now. tostring (), guid. newguid (). tostring (), jpjd, jpwd, "1", "yes", zcbm); SC. executenonqueryasync (SQL );