Home » Developer & Programmer » Reports & Discoverer » Report Formatting
Report Formatting [message #206396] Wed, 29 November 2006 22:09 Go to next message
cutsmartprem
Messages: 62
Registered: November 2006
Member
Well, the issue i am facing is :
one of my fields computes a sum, and if the sum turns out to be negetive then i am required to show it within SQUARE BRACKETS, but invariably the return type shoud be NUMBER. I Tried using varchar with success, but not with number-data type. I am Enclosing the PL/SQL code here..

function CF_1Formula return /*VARCHAR*/ NUMBER is
f number(17,5);
V VARCHAR2(23);
begin
f:=(:cf_2+ :cf_3 - :CS_1);


/*if f < 0 then

V := '('||f||')';
return V;
ELSE*/
RETURN(f);


/* return('('||f||')');

else return(f);*/

/*end if;*/

EXCEPTION WHEN NO_DATA_FOUND
THEN RETURN 'NULL';
end;




Please help me in this regard
Re: Report Formatting [message #206425 is a reply to message #206396] Thu, 30 November 2006 00:35 Go to previous messageGo to next message
Littlefoot
Messages: 20900
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As you've said that return type SHOULD (but does it mean 'MUST'?) be NUMBER, you'll have to use two formula columns: first one to compute sum (which will, as you requested, return a NUMBER), and the other one which will format this sum accordingly to another request - square brackets if the result is negative. Of course, this one will return CHARACTER.

Let's imagine that this table contains two columns: 'a' and 'b'. First function (which computes sum) looks like this:
function CF_1Formula return Number is
begin
  return (:a + :b);  
end;

Another one will format the result:
function CF_2Formula return Char is
begin
  if :cf_1 < 0 then
  	 return ('[' || to_char(abs(:cf_1)) || ']');
  else
  	 return to_char(:cf_1);
  end if;
end;

In paper layout, you'll display both columns 'a' and 'b', but NOT first formula column - you'll have to display the one that returns CHARACTER - 'CF_2'.

This could be simplified if you don't have to return a NUMBER - in that case, you'd avoid first formula column and do all job in the second one.

That's all, folks. Play ball.

[Updated on: Thu, 30 November 2006 00:36]

Report message to a moderator

Re: Report Formatting [message #206444 is a reply to message #206425] Thu, 30 November 2006 01:41 Go to previous message
cutsmartprem
Messages: 62
Registered: November 2006
Member
Thanks Littlefoot,

I tried out the solution.
It works fine. WIll getback to you if there are any problems.
Previous Topic: Report Out put
Next Topic: Copy selected values from a viewer report
Goto Forum:
  


Current Time: Wed Dec 07 20:29:19 CST 2016

Total time taken to generate the page: 0.10530 seconds