Use of insert in Oracle stored procedures, including the use of cursors
Body section:
-- Obtain the plan type number and name of the specified number of modifications for the specified stage of the specified plan by shiwei -- Used in the change stage
Procedure proc_sy_syjs_getAProChange (proID in release XT. sy_syjs_audit.FProID % type,
HistoryStageID in number,
Tab out t_cursor) is
CurStage number;
Begin
CurStage: =-1;
Select max (jt. fstageid) into curStage
From using XT. SY_SYJS_PROITEM jt
Where jt. fproid = proID
And jt. zt = 1;
If (curStage = 1) then
----- Initial change
Insert into XT. SY_SYJS_PROITEM (fproid, fstageid, fmodifyid, fcoursecode, fcoursename, fitemid, fitemname, ftype, fstyle, frequirement,
Flabmemnum, fgroupnum, fdevicename, fmodel, fhavenum, fobsonum, fbuynum, funitprice)
Select t. fproid, t. fstageid + 1, 0, t. fcoursecode, t. fcoursename, t. fitemid, t. fitemname, t. ftype, t. fstyle, t. frequirement,
T. flabmemnum, t. fgroupnum, t. fdevicename, t. fmodel, t. fhavenum, t. fobsonum, t. fbuynum, t. funitprice
From Rule XT. SY_SYJS_PROITEM t
Where t. fproid = proID
And t. fstageid = '1'
And t. zt = '1 ';
Commit;
Else
---- Copy data for two or more changes
Insert into XT. SY_SYJS_PROITEM (fproid, fstageid, fmodifyid, fcoursecode, fcoursename, fitemid, fitemname, ftype, fstyle, frequirement,
Flabmemnum, fgroupnum, fdevicename, fmodel, fhavenum, fobsonum, fbuynum, funitprice)
Select t. fproid, t. fstageid, t. fmodifyid + 1, t. fcoursecode, t. fcoursename, t. fitemid, t. fitemname, t. ftype, t. fstyle, t. frequirement,
T. flabmemnum, t. fgroupnum, t. fdevicename, t. fmodel, t. fhavenum, t. fobsonum, t. fbuynum, t. funitprice
From Rule XT. SY_SYJS_PROITEM t
Where t. fmodifyid = (select max (mt. fmodifyid) from nation XT. SY_SYJS_PROITEM mt
Where mt. fproid = proID
And mt. fstageid = '2'
And mt. zt = '1'
)
And t. fproid = proID
And t. fstageid = '2'
And t. zt = '1 ';
Commit;
End if;
Open tab
Select t. FProTypeID, t. FProTypeName from policxt. sy_syjs_audit t
Where FModifyID = (select max (t. fmodifyid) from nation XT. sy_syjs_proitem td
Where td. fproid = proID and td. fstageid = historyStageID
And td. zt = '1 ')
And t. fproid = proID and t. fstageid = historyStageID and t. zt = '1 ';
End;
Header file:
Procedure proc_sy_syjs_getAProChange (proID in release XT. sy_syjs_audit.FProID % type,
HistoryStageID in number,
Tab out t_cursor );