Results 1 to 6 of 6

Thread: Help with code

  1. #1
    Join Date
    Jul 2012
    Posts
    2

    Unanswered: Help with code

    Hi,
    i've made a psql script for my application in apex ,
    all the grades above 6 are shown in my designated page but all in 1 row ,
    how do i get each student,subject,grade on a row in a list ?

    thanks in advance ,
    script mentioned :

    declare
    cursor cur_stud is
    select student,vak,cijfer
    from z_tentamencijfer
    where cijfer > 6;

    r_studentcijfer cur_stud%ROWTYPE;
    begin
    Open cur_stud;
    LOOP
    fetch cur_stud into r_studentcijfer;
    exit when cur_stud%NOTFOUND;

    htp.print(r_studentcijfer.student || '-'||r_studentcijfer.vak || '-'||r_studentcijfer.cijfer);
    END LOOP;
    CLOSE cur_stud;
    end;
    Last edited by schoolws; 07-10-12 at 12:04.

  2. #2
    Join Date
    Aug 2003
    Location
    Where the Surf Meets the Turf @Del Mar, CA
    Posts
    7,776
    Provided Answers: 1
    >how do i get each student,subject,grade on a row in a list ?
    include some sort of newline character within the LOOP
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

  3. #3
    Join Date
    Jul 2012
    Posts
    2
    Quote Originally Posted by anacedent View Post
    >how do i get each student,subject,grade on a row in a list ?
    include some sort of newline character within the LOOP
    do you know how ? i want to show them for each student ( in number and pk )
    have looked into it but can't seem to resolve it

  4. #4
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    How about to use LISTAGG funcion?
    Like...
    htp.print(
    (SELECT LISTAGG(student || '-'||vak || '-'||cijfer , <some sort of newline character>) WITHIN GROUP(ORDER BY ...) from z_tentamencijfer where cijfer > 6)
    );

    Or, htp.print can't accept such long string at once?

  5. #5
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    Code:
    declare
    cursor cur_stud is 
    select student,vak,cijfer
    from z_tentamencijfer
    where cijfer > 6;
    
    r_studentcijfer cur_stud%ROWTYPE;  
    begin
    Open cur_stud;
    LOOP
    fetch cur_stud into r_studentcijfer;
    exit when cur_stud%NOTFOUND;	
    
    htp.print(r_studentcijfer.student || '-'||r_studentcijfer.vak     || '-'||r_studentcijfer.cijfer);
    htp.br;
    END LOOP;
    CLOSE cur_stud;
    end;
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

  6. #6
    Join Date
    Jun 2004
    Location
    Liverpool, NY USA
    Posts
    2,509
    I would suggest you look at the following link

    Oracle HTP Web HTTP
    Bill
    You do not need a parachute to skydive. You only need a parachute to skydive twice.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •