Hi Tom' s team,
Thank you for my previous question. I have a harder case,I try my best to fix that but it is not done.
My goal: When press print button, it will be automatically split many pdf files corresponded with for each of class of grade,, grade is a parameter I assign on the page of 241. (Ex: class_id 1 = pdf1, class_id 2 = pdf 2,.. And content of each pdf file is different.My present problem :After that, when I clicked Print, it showed me a single report includes all of student of class in grade and that was duplicate many times respectively with total number classes in a grade, that not what I expected. And When I checked on DB it run many reports but they have a same report and a value of class_id on DB, it always showed same value of the last id of class in grade( Ex: id = 1,2, 3,4 and then it showed all of value equal were 4) that thing I do not understand. When I checked on session state of page, it got only P241_class_id = 4.
That is my code for Print button:
DECLARE
l_document BLOB;
-- Select list of class in grade
Cursor c_subs is
select cl.id v_cl, cl.name
from e_edufit_class cl, e_edufit_grade gr
where gr.id = :P241_GRADE
and cl.grade_id = gr.id;
v_subs c_subs%Rowtype;
Begin
Open c_subs;
Loop
Fetch c_subs
into v_subs;
Exit when c_subs%Notfound;
-- That statement I want to assign each class of grade for page
Apex_Util.Set_Session_State('P241_CLASS_ID',v_subs.v_cl);
l_document := APEX_UTIL.GET_PRINT_DOCUMENT (
p_application_id =>1001,
p_report_query_name =>'test',
p_report_layout_name =>'test',
p_report_layout_type =>'rtf',
p_document_format =>'pdf',
p_print_server =>'f?p=&APP_ID.:0:&SESSION.:PRINT_REPORT=test');
insert into report_archive (
filename,
mimetype,
report,
created_date,
created_by,
<b>class_id</b>
) values (
v_subs.name,
'application/pdf',
l_document,
sysdate,
:USER_ID,
:P241_CLASS_ID
);
end loop;
commit;
END;
and then, that is code of my report query:
select rownum STT,
cl.CODE,
cl.NAME CL,
cl.DESCRIPTION,
gr.name GR,
y.name ,
cm.id_user Student,
from E_EDUFIT_CLASS cl, e_edufit_grade gr, e_school_year y, E_EDUFIT_CLASS_MEMBERS cm
where cl.grade_id = gr.id
and cl.SCHOOL_YEAR_ID = y.id
and (GRADE_ID = :P241_GRADE or :P241_GRADE is null)
AND cm.id_class = :P241_CLASS_ID
And I used session state and select items P241_CLASS_ID
I hope that time I describe my problem more clearly to you. Thank in advance ^_^