create or replace
PROCEDURE PAID_REPORT
(
PAYMENT_STATUS IN VARCHAR2
) AS
linecount number(4);
linecounttwo number(4);
--animal varchar2 (12);
animaltype varchar2(12);
visitid number (6);
cursor vetCursor is
select pb_vet.vetid,visitid,lastname,firstname
from pb_visit,pb_vet
where pb_visit.vetid = pb_vet.vetid
and pb_visit.status = PAYMENT_STATUS
order by lastname, firstname;
vetRow vetCursor%rowtype;
cursor visitCursor is
select visitid,name,lastname,firstname
from pb_client,pb_animal,pb_visit
where pb_client.cliEntid=pb_animal.clientid
and pb_visit.animalid=pb_animal.animalid
and status = PAYMENT_STATUS;
visitRow visitCursor%rowtype;
BEGIN
linecounttwo:=0;
open visitCursor;
loop
fetch visitCursor
into visitRow;
exit when visitCursor%notfound;
linecounttwo:=linecounttwo+1;
end loop;
linecount:=0;
open vetCursor;
loop
fetch vetCursor
into vetRow;
exit when vetCursor%notfound;
dbms_output.put_line('Veterinarian ID: '||vetRow.vetid||' '||vetRow.lastname||','||vetRow.firstname);
linecount:=linecount+1;
end loop;
close vetCursor;
END PAID_REPORT;
数行の VETID 情報が出力されます。私がやりたいことは、各 vetID の下で、この vetID を別の select 文で使用して、select ...from...where id=vetID のようなものを検索したいということです。
予想どおり 2 行の vetID が表示されましたが、使い方がわかりません。英語は私の母国語ではないので、自分自身を明確にしたかどうかはわかりません。そのため、簡単な例を使用して、やりたいことを示します。
CLASS ID: 0001 英語
Student A 19
Student B 21
CLASS ID: 0004 数学
Student A 19
Student B 21
CLASS ID の行を取得したようなものです。次に、各 CLASS ID に対して、それを選択名、学生からの年齢として使用したいと考えています。問題は、CLASS IDが何であるかわかりません..
ありがとうございました。任意の助けをいただければ幸いです。