CHANGING RECORD ACCORDING TO VALUE [message #299806] |
Wed, 13 February 2008 04:44 |
AHMADF124
Messages: 30 Registered: January 2008 Location: KSA
|
Member |
|
|
Dear All ,
can you help me to solve this problem, I am creating a report to retrieve all employees with basic salary, but I should have to change the text color of salary to red in case of the employee salary less than any other employees in his department and his hire date is grater then other, i do the following :
1- In the format trigger I wrote the following code:
///////////////////////////////////////////////////////////
function F_BASICSALRYFormatTrigger return boolean is
cursor c4 is select rownum,to_char(hiredate,'YYYY'),basicsalry from pahempm
where empno=:empno and ROWNUM = rownum-1 ;
v_hiredate date;
v_basic number;
V_ROW NUMBER;
begin
open c4;
fetch c4 into v_row,v_hiredate,v_basic;
if v_hiredate < to_char(:hiredate,'YYYY') AND v_basic < :basicSALRY then
SRW.SET_TEXT_COLOR('RED');
ELSE
SRW.SET_TEXT_COLOR('BLACK');
END IF;
close c4;
return (TRUE);
end;
///////////////////////////////////////////////////////////////
This will compare previous employee with next employee, but all of them are the same nothing changed, so help me please.
Thanks,,,,
|
|
|
|
Re: CHANGING RECORD ACCORDING TO VALUE [message #299870 is a reply to message #299825] |
Wed, 13 February 2008 07:54 |
AHMADF124
Messages: 30 Registered: January 2008 Location: KSA
|
Member |
|
|
Thank you littlefoot for the advice, I had solve the problem by counting the employees that they are out of cretiria and if the counter return 0 then it will be in black other wise it will be in red.
the follwoing is my code:
function F_BASICSALRYFormatTrigger return boolean is
V_COUNT NUMBER;
BEGIN
SELECT COUNT(*)
INTO V_COUNT
FROM PAHEMPM
WHERE CATEGORY=(SELECT CATEGORY
FROM PAHEMPM
WHERE EMPNO=:EMPNO)
AND BASICSALRY >(SELECT BASICSALRY
FROM PAHEMPM
WHERE EMPNO=:EMPNO)
AND TO_CHAR(HIREDATE,'YYYY') <= (SELECT TO_CHAR(HIREDATE,'YYYY')
FROM PAHEMPM WHERE EMPNO=:EMPNO);
IF V_COUNT > 0 THEN
SRW.SET_TEXT_COLOR('RED');
ELSE
SRW.SET_TEXT_COLOR('BLACK');
END IF;
return (TRUE);
end;
thank you again.
[Updated on: Wed, 13 February 2008 07:59] Report message to a moderator
|
|
|