Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Oracle procedure to read the rows

$
0
0
Hi guys,

I need to modify the procedure to read all the lines of a text.Actually in my table
there is a personnel number column with duplicates and a TEXT column.I need to
create a procedure to read all the text per personnel number and insert it into a another table.The below code is the procedure which is reading the two lines of text field.Please let me know how can I modify it to read all the text per personnel number.

Thanks in advance.

create PROCEDURE hr_load_restict_text_proc
as
CURSOR cur_hr_restrict
IS
SELECT personnel_number, line
FROM hr_restriction_text_temp
ORDER BY personnel_number, examination_date;

lv_hr_rec cur_hr_restrict%ROWTYPE := NULL;
lv_hr_perno hr_restriction_text_temp.personnel_number%TYPE := NULL;
lv_upd_perno hr_restriction_text_temp.personnel_number%TYPE := 'X';
lv_commit_num PLS_INTEGER := 19999;
lv_counter_num PLS_INTEGER := 0;
lv_prod_obj VARCHAR2 (3) := 'AMR';
BEGIN
-- log_err('hr_load_restict_text_proc: ',lv_prod_obj, 'START' ) ;
/* truncate DIM table */
EXECUTE IMMEDIATE 'TRUNCATE TABLE hr_restriction_text_dim';

lv_counter_num := 0;

<<hr_loop>>
FOR lv_hr_rec IN cur_hr_restrict
LOOP
IF (lv_upd_perno <> lv_hr_rec.personnel_number)
THEN
BEGIN
lv_hr_perno := lv_hr_rec.personnel_number;

INSERT INTO hr_restriction_text_dim (personnel_number,
restriction_text)
VALUES (lv_hr_rec.personnel_number, lv_hr_rec.line
);

lv_counter_num := lv_counter_num + SQL%ROWCOUNT;
EXCEPTION
WHEN DUP_VAL_ON_INDEX
THEN
UPDATE hr_restriction_text_dim
SET restriction_text =
RTRIM (restriction_text || ' ' || lv_hr_rec.line)
WHERE personnel_number = lv_hr_rec.personnel_number;

lv_upd_perno := lv_hr_rec.personnel_number;
lv_counter_num := lv_counter_num + SQL%ROWCOUNT;
END;
END IF;

adm_load_dims_pkg.adm_do_commit (lv_counter_num, lv_commit_num);
END LOOP hr_loop;
END hr_load_restict_text_proc;
exec hr_load_restict_text_proc;

Viewing all articles
Browse latest Browse all 13329

Trending Articles