Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2012
    Posts
    3

    can we use group by clause in cursor

    hie, how can we use group by clause in select statement for cursor.

    for example
    i used

    CREATE OR REPLACE PROCEDURE SHOW_ATTENDANCE_RECORD
    AS
    CURSOR ATT_PEOPLE IS
    SELECT c.MID COUNT(c.ATT)
    FROM ATTENDANCE c,
    WHERE c.ATT = '&ATT'
    GROUP BY c.MID
    BEGIN
    FOR DISPLAY IN ATT_PEOPLE LOOP
    DBMS_OUTPUT.PUT_LINE('ID NO:'||display.MID, COUNT(c.ATT));
    END LOOP;
    END;

    how can we show the count in the procedure and use the group by clause in order to do so ..

    many thanks

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,013
    No problem in using GROUP BY in cursor (your code is invalid; misses comma between MID and COUNT; has comma in the FROM clause; misses a terminating semi-colon after the GROUP BY clause and maybe something else which I didn't bother to find. Please, don't post rubbish code - check it first!).

    DBMS_OUTPUT.PUT_LINE accepts one parameter so you'll have to concatenate all you want to display.

Posting Permissions

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