Use of insert in Oracle stored procedures, including the use of cursors

Source: Internet
Author: User

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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.