0
如何使用記錄變量檢索遊標實現中的count值?從光標打印聚合函數的結果
DECLARE
CURSOR cur_branch IS
SELECT b.branchname, COUNT(a.applicantid)
FROM branch b, applicant a
WHERE b.branchid=a.optedbranch
GROUP BY b.branchname ORDER BY b.branchname;
BEGIN
DBMS_OUTPUT.PUT_LINE('Branch Name No of Applicants opted');
FOR v_branchrec IN cur_branch
LOOP
DBMS_OUTPUT.PUT(RPAD(v_branchrec.branchname,20)||' ');
DBMS_OUTPUT.PUT_LINE(v_branchrec.COUNT(applicantid));
END LOOP;
END;
這將引發錯誤的DBMS_OUTPUT.PUT_LINE(v_branchrec.COUNT(applicantid));
指出COUNT都將被聲明,它可以只用於SQL而不是PL/SQL。
我想檢索每個科室的學生人數。