Use of Oracle Cursors

Source: Internet
Author: User

Well, always lift the cursor on the headache, the total feeling is very tall things, deterred ...

What to do today involves updating data in real time, using a job stored procedure cursor

Through on-line search information, consult colleagues, also began to continue to go deep Oracle,,,, side dishes ...

Make a note that will be easy to see later

CREATE OR REPLACE PROCEDURE cost_mes_sl_init_sp_001 (p_sysdate DATE) is
V_p_sysdate DATE;
V_year number;
V_month number;

Cursor C_FACILITY_ID is--create cursor
SELECT facility_id
From COST_BASE_FACILITY_VW
WHERE 1 = 1/* facility_id in (SELECT facility_id
From ZZYX_USER_JLMES_FACILITY_TB T
WHERE user_id = {$SYS _userid$}) */
and u_lower = 1
ORDER by U_order;

R_FACILITY_ID C_facility_id%rowtype; Defines a cursor variable that I understand as an object

BEGIN

V_p_sysdate: = p_sysdate;
SELECT add_months (TRUNC (Sysdate),-1) into v_p_sysdate from DUAL; --Get last month's date

V_year: = EXTRACT (year from v_p_sysdate); -year
V_month: = EXTRACT (month from v_p_sysdate);

Open c_facility_id;--Opening cursors
loop--start loop cursor
FETCH c_facility_id
into r_facility_id;
EXIT when C_facility_id%notfound;
COST_MES_SL_INIT_SP (r_facility_id.  facility_id, V_year, V_month); --Call another stored procedure
END LOOP; --End Loop
CLOSE c_facility_id; --Close cursor
COMMIT;
END cost_mes_sl_init_sp_001;

Use of Oracle Cursors

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.