Home » Developer & Programmer » Reports & Discoverer » order by in a function
order by in a function [message #171201] Tue, 09 May 2006 00:45 Go to next message
indraneelkumar
Messages: 24
Registered: September 2005
Location: bangalore
Junior Member

Hi

In Reports In Formula column I am writing a cursor(pl/sql formula) when I am compailing it gives an error as "encountered symbol "ORDER" when expecting one of following"
If I comment the order by caluse working properly

I executed same cursor in back end it working properly
Why it is giving error in reports
plz help me


SELECT * FROM (
      SELECT  MAX(PEMPH_END_NO_IDX),POLH_SYS_ID,PEMPH_SPOUSE_YN, PEMPH_CHILD_YN
      FROM    PH_GL_POLICY,PH_GL_POL_EMPLOYEE
      WHERE   POLH_SYS_ID = PEMPH_POL_SYS_ID 
      AND     NVL(POLH_MASTER_POLICY_NO,0) BETWEEN :P_FM_MAST_POL_NO AND :P_TO_MAST_POL_NO
      AND     POLH_NO BETWEEN :P_FM_POL_NO AND :P_TO_POL_NO
      AND     POLH_NO NOT IN (SELECT  POLH_NO 
                              FROM    PH_GL_POLICY B
			      WHERE   B.POLH_SYS_ID = POLH_SYS_ID
			      AND     B.POLH_STATUS = 'C'
                              AND     :P_AS_OF_DT >=  B.POLH_END_EFF_FM_DT)
      AND     PEMPH_SYS_ID NOT IN (SELECT  PEMPH_SYS_ID
                                   FROM    PH_GL_POL_EMPLOYEE E
	                           WHERE   E.PEMPH_SYS_ID = PEMPH_SYS_ID
                       	           AND     E.PEMPH_POL_SYS_ID =   POLH_SYS_ID
                         	   AND     :P_AS_OF_DT >= E.PEMPH_EXIT_DT)	
      AND     PEMPH_ID = :Q1_PEMPH_ID1                    	         
      AND     :P_AS_OF_DT BETWEEN POLH_FM_DT AND POLH_TO_DT
      GROUP BY POLH_SYS_ID,PEMPH_SPOUSE_YN, PEMPH_CHILD_YN
	  ORDER BY PEMPH_SPOUSE_YN DESC,PEMPH_CHILD_YN DESC )
	  WHERE ROWNUM =1 ;     



Thanks in advance
Re: order by in a function [message #171772 is a reply to message #171201] Thu, 11 May 2006 07:39 Go to previous messageGo to next message
Littlefoot
Messages: 21811
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Formula column should have a return value. Are you returning a single value or trying to return the whole record?

SELECT statement should have an INTO clause - where is INTO in your statement?

This is a dummy formula which actually compiles and works (Report Builder 9.0.4); can you make it work too, just to test it?
function CF_1Formula return Number is
  retval emp.empno%type;
begin
  SELECT * 
  INTO retval
  FROM 
    (SELECT MAX(empno)
     FROM EMP
     GROUP BY ename
     ORDER BY ename
    ) 
  WHERE ROWNUM = 1;

  RETURN (retval);
end;
Re: order by in a function [message #172025 is a reply to message #171772] Sat, 13 May 2006 05:38 Go to previous messageGo to next message
hanon_ocp
Messages: 4
Registered: May 2006
Location: Egypt
Junior Member
Dear indraneelkumar
if ur query works just fine on sql plus then
this problem can be due to the difference between the pl/sql engine used in reports
and the engine used in the server
i had asimiliar situition before
where he objected on the order by clause in the report while it is working fine as sql statment


SOULTION :

Try to make your formula on database
as database function
and just calling it from report passing the appropriate parameters.
please feed me back
note :
Dear Littlefoot

the sql statment is not a select statment whiche requir into clause
it is a cursor only
defined in the declare section of formula

thanx
urs Eng.Hany

[Updated on: Sat, 13 May 2006 05:39]

Report message to a moderator

Re: order by in a function [message #172029 is a reply to message #172025] Sat, 13 May 2006 07:02 Go to previous message
Littlefoot
Messages: 21811
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
"... it is a cursor only defined in the declare section of formula"

Right; that never crossed my mind Smile
Previous Topic: how create parameter form (not user parameter)
Next Topic: Arabic font problem in Reports
Goto Forum:
  


Current Time: Sat Jun 29 02:17:30 CDT 2024