Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: please convert oracle code to crystal Post Reply Post New Topic
Author Message
kotomoto
Newbie
Newbie


Joined: 09 Feb 2009
Online Status: Offline
Posts: 2
Quote kotomoto Replybullet Topic: please convert oracle code to crystal
     Posted: 09 Feb 2009 at 2:54am
Hi there
I have oracle code , i need to transfer it to crystal in formule
 
the code is:
 
get_section_grade_avg (p_term student_course.ACADEMIC_PERIOD%type,p_cn student_course.COURSE_NUMBER%type,
                       p_campus student_course.campus%type,p_college student_course.college%type,
                       p_csn student_course.COURSE_section_NUMBER%type)
RETURN number

IS
cursor c1 is select  DECODE(FINAL_GRADE,'A',4,'B+',3.5,'B',3,'C+',2.5,'C',2,'D+',1.5,'D',1,'F',0,-1) val,count(*) num
from student_course
where ACADEMIC_PERIOD = p_term
AND COURSE_NUMBER = p_cn
and campus=p_campus
and college=p_college
and COURSE_section_NUMBER=p_csn
group by ACADEMIC_PERIOD,college,COURSE_NUMBER,FINAL_GRADE,COURSE_section_NUMBER,campus,FINAL_GRADE;

v_count number:=0;
v_sum number:=0;
v_avg number:=0;
v_message varchar2(200);
BEGIN
for i in c1 loop
if i.val<>-1 then
v_sum := v_sum+i.val*i.num;
v_count := v_count+i.num;
end if;
end loop;
if v_sum=0 or v_count=0 then
return 0;
else
v_avg:=v_sum/v_count;
--v_message:='sum = '||v_sum||'count = '||v_count||'avg = '||v_avg ;
--return   v_message;
return round(v_avg,3);
end if;

END;
/
 
please i need it very important
IP IP Logged
Handsome-Hal
Newbie
Newbie
Avatar

Joined: 06 Feb 2009
Location: United States
Online Status: Offline
Posts: 7
Quote Handsome-Hal Replybullet Posted: 09 Feb 2009 at 12:30pm
Why don't you just make this an Oracle View or a procedure that populates a Table that is updated at regular intervals, and then make your Crystal report pointing to the View or Table for it's data?

Why recreate the work?


Edited by Handsome-Hal - 09 Feb 2009 at 12:31pm
IP IP Logged
kotomoto
Newbie
Newbie


Joined: 09 Feb 2009
Online Status: Offline
Posts: 2
Quote kotomoto Replybullet Posted: 09 Feb 2009 at 7:20pm
because in my work need to transfer all report in oracle to crystal...
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 10 Feb 2009 at 3:23pm
In the report, set up a group for each of the fields that you need to to get to the section level of the data.
 
To get the number value for the grade, try a formula like this (I'll call it {@GradeVal}):
 
Switch(
{student_course.FINAL_GRADE} = 'A', 4,
{student_course.FINAL_GRADE} = 'B+', 3.5,
{student_course.FINAL_GRADE} = 'B', 3,
{student_course.FINAL_GRADE} = 'C+', 2.5,
{student_course.FINAL_GRADE} = 'C', 2,
{student_course.FINAL_GRADE} = 'D+', 1.5,
{student_course.FINAL_GRADE} = 'D', 1,
{student_course.FINAL_GRADE} = 'F', 0,
-1
)
 
To get the average for the section, go to the Insert menu and select Summary.  
 
Chose Field to Summarize = {@GradeVal} formula
Calculate This Summary = Average
Summary Location = your section group
 
-Dell
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum