ORA-01403: данные не найдены. Код получает идентификатор (UIN) из файла .txt и загружает их в файл. Ожидается, что мой выходной файл будет иметь только заголовок и никаких записей в нем, когда данные не найдены. но при выполнении процедуры он не выдает данных об ошибке. Я что-то упустил в определении курсора или для цикла?
PROCEDURE pwt_test_5 (
in_term_code IN VARCHAR2
) AS
a_uin_input_file utl_file.file_type;
a_out_file utl_file.file_type;
a_uin_record VARCHAR2(5000);
CURSOR get_details_4_uin_c IS ---cursor to get details for the UIN
SELECT
spriden_id AS uin,
f_format_name(spriden_pidm, 'LF') AS full_name,
sfrstcr_bill_hr AS enrolled_hours,
sgbstdn_program_1 AS program,
sgrchrt_chrt_code AS cohort_rate,
SUM(tbraccd_balance) AS current_sbs_balance,
sgbstdn_camp_code AS campus_enrolled
FROM
sfrstcr
JOIN spriden ON spriden_pidm = sfrstcr_pidm - gets the id from the input file
AND spriden_ntyp_code = 'UIN'
AND spriden_id = a_uin_record
AND spriden_change_ind = 'I'
JOIN sgbstdn s1 ON s1.sgbstdn_pidm = sfrstcr_pidm
AND s1.sgbstdn_term_code_eff = (
SELECT
MAX(s2.sgbstdn_term_code_eff)
FROM
sgbstdn s2
WHERE
s2.sgbstdn_pidm = s1.sgbstdn_pidm
AND substr(s2.sgbstdn_term_code_eff, 1, 5) <= sfrstcr_term_code
)
JOIN sgrchrt a ON a.sgrchrt_pidm = sfrstcr_pidm
AND a.sgrchrt_term_code_eff = (
SELECT
MAX(mx.sgrchrt_term_code_eff)
FROM
sgrchrt mx
WHERE
mx.sgrchrt_pidm = a.sgrchrt_pidm
AND mx.sgrchrt_term_code_eff <= sfrstcr_term_code
)
JOIN tbraccd ON sfrstcr_term_code = tbraccd_term_code
AND sfrstcr_pidm = tbraccd_pidm
WHERE
sfrstcr_term_code = in_term_code
GROUP BY
spriden_id, spriden_pidm,
sfrstcr_bill_hr,
sgbstdn_program_1,
sgrchrt_chrt_code,
sgbstdn_camp_code;
BEGIN
a_uin_input_file := utl_file.fopen('TAMUIN', 'uins.txt', 'r');
a_out_file := utl_file.fopen('TAMUOUT', 'twkarchana_6.csv', 'w', '32767');
utl_file.put_line(a_out_file, 'sep=;');
utl_file.put_line(a_out_file, 'UIN' --output file headers
|| ';'
|| 'Name'
|| ';'
|| 'Hours Registered'
|| ';'
|| 'Program'
|| ';'
|| 'Cohort Rate'
|| ';'
|| 'Current SBS Balance'
|| ';'
|| 'Campus Enrolled', autoflush => true);
LOOP
utl_file.get_line(a_uin_input_file, a_uin_record); - get from the i/p .txt
FOR rec IN get_details_4_uin_c LOOP utl_file.put_line(a_out_file, rec.uin -write to the external.csv
|| ';'
|| rec.full_name
|| ';'
|| rec.enrolled_hours
|| ';'
|| rec.program
|| ';'
|| rec.cohort_rate
|| ';'
|| rec.current_sbs_balance
|| ';'
|| rec.campus_enrolled, autoflush => true);
END LOOP;
END LOOP;
utl_file.fclose(a_uin_input_file); --close the files
utl_file.fclose(a_out_file);
END pwt_test_5;
Я пытался переписать курсор.