用Fetch into a cursor%TYPE把要處理的數據放到記錄集裡
FUNCTION CalculateImportCharge (
p_i_job_id IN VARCHAR
p_i_as_of_date_id IN VARCHAR
AS
CURSOR cur_ShipBlHeader IS
SELECT import_folder_no
FROM GMY_SHIP_BL_HEADER
WHERE CANCEL_FLG = GMY_GA
rec_ShipBlHeader cur_ShipBlHeader%ROWTYPE;
BEGIN
OPEN cur_ShipBlHeader;
FETCH cur_ShipBlHeader INTO rec_ShipBlHeader;
WHILE cur_ShipBlHeader%FOUND LOOP
x_num_error_code := GMY_GA
p_i_job_id
p_i_as_of_date_id
rec_ShipBlHeader
x_vch_message);
IF x_num_error_code
IN (GMY_GA
x_vch_message :=
p_i_job_id
||
||
|| rec_ShipBlHeader
||
COM_LOG
GOTO NEXT_RECORD;
END IF;
x_num_error_code := CheckExistsOfAccDate (
p_i_job_id
p_i_as_of_date_id
rec_ShipBlHeader
IF x_num_error_code = GMY_GA
GOTO NEXT_RECORD;
END IF;
COMMIT;
<<NEXT_RECORD>>
FETCH cur_ShipBlHeader INTO rec_ShipBlHeader;
END LOOP;
CLOSE cur_ShipBlHeader;
RETURN GMY_GA
EXCEPTION
WHEN OTHERS THEN
x_vch_message :=
p_i_job_id
||
|| SUBSTR (SQLERRM (SQLCODE)
COM_LOG
RETURN GMY_GA
END CalculateImportCharge;
FUNCTION GenerateInsCostInfRec (
p_i_job_id IN VARCHAR
p_i_as_of_date_id IN VARCHAR
AS
CURSOR cur_cost IS
SELECT cost
cost
cost
FROM GMY_COST_BL cost
GMY_COMMON_MST mst
WHERE cost
AND cost
AND cost
AND cost
BEGIN
FOR rec_cost IN cur_cost LOOP
BEGIN
x_num_ret_value := GMY_GA
p_i_job_id
p_i_as_of_date_id
rec_cost
x_vch_error_msg);
IF x_num_ret_value = GMY_GA
INSERT INTO GMY_COST_INS_INF(
cost_trx_id
created_by
program_name)
VALUES(
GMY_COST_INS_INF_S
PRG_NAME
PRG_NAME);
ELSIF x_num_ret_value = GMY_GA
x_vch_error_msg := p_i_job_id
||
|| rec_cost
||
||
COM_LOG
END IF;
EXCEPTION
WHEN OTHERS THEN
IF SQL%ROWCOUNT >
x_vch_error_msg := p_i_job_id||
SUBSTR(SQLERRM(SQLCODE)
COM_LOG
ELSE
x_vch_error_msg := p_i_job_id||
SUBSTR(SQLERRM(SQLCODE)
COM_LOG
END IF;
END;
END LOOP;
COMMIT;
RETURN GMY_GA
EXCEPTION
WHEN OTHERS THEN
x_vch_error_msg := p_i_job_id||
COM_LOG
ROLLBACK;
RETURN GMY_GA
END GenerateInsCostInfRec;
FUNCTION CopyDsToActualDs (
p_i_job_id IN VARCHAR
p_i_as_of_date_id IN VARCHAR
IS
CURSOR cur_DsScc IS
SELECT *
FROM GMY_DS_SCC;
BEGIN
FOR rec_DsHead IN cur_DsScc LOOP
x_num_error_code := InsToActualScc(
From:http://tw.wingwit.com/Article/program/Oracle/201311/18441.html