If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > can we use group by clause in cursor

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #2 (permalink)  
Old
Lost Boy
 
Join Date: Jan 2004
Location: Croatia, Europe
Posts: 3,986
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On