FOR LOOP in CURSOR not working properly
782404Aug 5 2010 — edited Aug 5 2010Hi friends,
I have problem with this cursor. Below is the portion of the code... It should displays all acts and details of the accused in the email being sent to officer, but until now only 1 act out of 2 being displayed. Code must repeat Name, No of Trial, Act, Section for the Act No 6, Insurance Claim. What else should I do? Thanks..
lpad('Trial Information ', 50)||CHR(10)||CHR(10);
OPEN trial_cur;
FETCH trial_cur into trial_rec.accused_id, trial_rec.accused_name, trial_rec.no_of_trial,
trial_rec.act, trial_rec.act_detail, trial_rec.section, trial_rec.section_detail;
EXIT WHEN trial_cur%NOTFOUND;
while trial_cur%FOUND loop
accused_name := lpad('Name : ', 50)||trial_rec.accused_id|' '||trial_rec.accused_name||CHR(10);
no_of_trial := lpad('No of Trial : ', 50)||trial_rec.no_of_trial||CHR(10);
act := lpad('Act : ', 50)||trial_rec.act||' '||trial_rec.act_detail||CHR(10);
section := lpad('Section : ', 50)||trial_rec.section||' '||trial_rec.section_detail||CHR(10)||CHR(10);
fetch trial_cur into trial_rec.accused_id, trial_rec.accused_name, trial_rec.no_of_trial,
trial_rec.act, trial_rec.act_detail, trial_rec.section, trial_rec.section_detail;
END LOOP;
CLOSE trial_cur;
thank := 'Thank you.';
Email being sent to officer:
. . .
Trial Information
Name : AA001 ACCUSED1
No of Trial : Fifth
Act : ACT 5 Criminal Act 1990
Section : Section 5B. Drug Trafficking.
Thank you.
Data stored in database:
ACCUSED_ID ACCUSED_NAME NO_OF_TRIAL ACT ACT_DETAIL SECTION SECTION_DETAIL
AA001 ACCUSED1 Sixth ACT 6 Sivil Act 1999 Section 6D. Insurance Claim.
AA001 ACCUSED1 Fifth ACT 5 Criminal Act 1990 Section 5B. Drug Trafficking.
Thank you.