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