ORACLE Learning Notebooks

Source: Internet
Author: User

Commit is equal to commit in proc
When you do insert or UPDATE, the commit is actually modified or inserted into the database.

If you don't commit, the watch will be locked.


CURSOR MyCursor is--defining the tour target
SELECT A.applykind_no,a.fac_no,a.building_no,a.deptkind_no,a.dutyrank_no,a.approval_sort,a.approvalrank_no,
A.APPDEPT_NO,A.APPROVAL_TYPE,NVL (A.APPROVAL_MK, ' N ') approval_mk
From Approvalset_duty A
WHERE A.applykind_no=vapplykind_no
and A.FAC_NO=VFAC
and A.BUILDING_NO=NVL (vbuilding, ' A ')
and a.deptkind_no= (SELECT deptkind_no from appdept WHERE appdept_no=vappdept_no)
and A.dutyrank_no=vdutyrank_no;
BEGIN
Vfac:=vfac_no;

If vfac_no= ' HR ' then
vfac:= ' 311 ';
END IF;
IF vfac_no= ' HGHR ' then
vfac:= ' 346 ';
END IF;

OPEN mycursor;
Loop--loop start flag

--

FETCH MyCursor into Vvapplykind_no,vvfac_no,vvbuilding_no,vvdeptkind_no,vvdutyrank_no,
VVAPPROVAL_SORT,VVAPPROVALRANK_NO,VVAPPDEPT_NO,VVAPPROVAL_TYPE,VVAPPROVAL_MK;

3. Properties

3.1,%isopen to determine whether the cursor is open, if open, then%isopen equals true; otherwise equals false.

3.2.%found determine if the cursor row is valid. If valid,%found equals true; otherwise equals false.

3.3,%notfound and%found similar, the function is opposite.

3.4.%rowcount returns the number of record rows that the cursor reads until the current position.


EXIT whenMyCursor%notfound;
--Dbms_output. Put_Line (' AA ' | | '.. ' | | ' AA ');--Tests
DELETE from Approval_set WHERE apply_no=vapply_no and Appdept_sort=vvapproval_sort;
DELETE from the APPLY WHERE apply_no=vapply_no;

IF vvapproval_mk= ' Y ' then
Vappdept:=vappdept_no;
ELSE
Vappdept:= Vvappdept_no;
END IF;

INSERT into Approval_set (APPLY_NO,APPDEPT_SORT,APPLYKIND_NO,APPROVALRANK_NO,FAC_NO,APPDEPT_NO,APPROVAL_MK, Approval_type)
VALUES (Vapply_no,vvapproval_sort,vvapplykind_no,vvapprovalrank_no,vvfac_no,vappdept,vvapproval_mk,vvapproval_ TYPE);

INSERT into APPLY (Apply_no,apply_content,apply_date,fac_no,sec_no,applydept_no,applykind_no,dutyrank_no, APPLYUSER_NO,APPROVALFINISH_MK)
VALUES (vapply_no,vvfac_no| | vsec_no| | Vappdept,vapply_date,vvfac_no,vsec_no,vappdept,vvapplykind_no,vdutyrank_no,vapplyuser_no, ' N ');
COMMIT;

END LOOP;
CLOSE mycursor;
COMMIT;
End

ORACLE Learning Notebooks

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.