Reports: how to find page number and total number of pages? [message #440773] |
Tue, 26 January 2010 23:46 |
|
Dear all my friends
Please guide me and give me query for this type
i am ussing oracle developer 6i report builder i required this type of query
exmple
if (:page number LIKE '1')
then
srw.set_text_color('darkred');
end if;
return (TRUE);
end;
but page number is not my table database item how can i use builtan page &<pagenumber> use for conditional format.
thanks
please reply fast everyone.
[EDITED by LF: modified topic title. The original was "Oracle Report Developer 6i (urgent Help)"]
[Updated on: Thu, 28 January 2010 02:48] by Moderator Report message to a moderator
|
|
|
|
Re: Oracle Report Developer 6i (urgent Help) [message #440832 is a reply to message #440816] |
Wed, 27 January 2010 05:33 |
|
thanks sir
2nd question is required
Please how can define query urgently reply please.
Exmple
Create a format trigger; this example shows a trigger on a field:
function F_enameFormatTrigger return boolean is
l_page_num number;
begin
srw.get_page_num (l_page_num);
if l_page_num = 'Last Page' then
srw.set_text_color('darkred');
end if;
return (true);
end;
|
|
|
Re: Oracle Report Developer 6i (urgent Help) [message #440838 is a reply to message #440832] |
Wed, 27 January 2010 05:47 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
"Last page"? I'm not sure it exists. It is something like Yeti - there are rumors that someone saw it, but there's no evidence.
The same goes for the last report page - you don't know it, until the report reaches it. As there's no SRW "get_total_number_of_pages", I really wouldn't know how to do that. As I've said - now and then people ask the same question, but I didn't see an answer. You can search the board, though, perhaps you'll find something useful.
As of your "urgent" questions - come on, this is just a forum. You might, or might not get the answer - today, tomorrow, next week, never - who can tell? For "urgent" problems contact Oracle Support or hire a consultant.
|
|
|
|
Re: Oracle Report Developer 6i (urgent Help) [message #440965 is a reply to message #440844] |
Thu, 28 January 2010 02:21 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Thank you, @ramoradba! It seems that Metalink note 130432.1 solves the problem. As it is protected by copyright, we can't attach it here. However, I spent some time trying to follow instructions and - here it goes, for future reference (so that I won't have to lie about us being unable to do that).
I used Reports Developer 10g, connected to Oracle database 10g.
Using a Wizard, I created a „dummy" report which spans several pages (as I need more than a single-page-report); this is a Scott's schema based Cartesian product on EMP table:select e1.ename, e2.job
from emp e1, emp e2
The objective is to display employee name in dark red color on the last report page. Something like this:if page_number = last_page then
paint(ename, dark red);
end if;
In Object Navigator, create a package. Metalink document also suggests use of a table which stores session ID as well as total number of pages, but I chose a package instead.
A package variable will contain total number of pages:package pkg_page_num is
p_tpn number; -- "tpn" stands for "total pages number"
end;
In Paper Layout editor, create additional field, „F_total_pages" whose source is „Total Pages".
Now create Format Trigger for the „F_total_pages" field:
function F_total_pagesFormatTrigger return boolean is
l_page_num number;
begin
srw.get_page_num(l_page_num);
pkg_page_num.p_tpn := nvl(pkg_page_num.p_tpn, l_page_num);
return (TRUE);
end;
What does it do: - create a local variable (l_page_num) which will contain page number
- Page number will be retrieved with SRW built-in package and its GET_PAGE_NUM function
- Store page number into the package variable.
NVL function differs from Metalink description; if NVL is not used, total number of pages is wrong and it appears that „page number" is never equal to „total number of pages". I've checked what was going on (using the SRW.MESSAGE), and total number of pages was changing its value when scrolling through report pages, but was never (except for the first report run) correct.
On the other hand, if a table was used, we'd store „total number of pages" into that table and select MAX value from a table. If that was the case, NVL wouldn't be necessary. Another option might be use of the GREATEST function. Obviously, there are variations to the solution, which is marvelous! It would be a shame if there was none.
Next, ENAME field's format trigger (as we want to paint it red):
function F_enameFormatTrigger return boolean is
l_page_num number;
begin
srw.get_page_num(l_page_num);
if l_page_num = pkg_page_num.p_tpn then
srw.set_text_color('darkred');
end if;
return (TRUE);
end;
What does it do?- create a local variable (l_page_num) which will contain page number
- if it is equal to the „last page number" (which is now stored in the package variable, "pkg_page_num.p_tpn"), do „something" (for example, paint values red)
That's all; now run the report: on page 4/5, ENAME values are black.
On the last page (5/5), they are red.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Oracle Report Developer 6i (urgent Help) [message #441082 is a reply to message #441034] |
Thu, 28 January 2010 10:20 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Unfortunately, there's no SRW.GET_LAST_PAGE_NUM. Therefore, we have to use workaround. It is described on Metalink. I tried to do that for you - and it seems that it works just fine, at least on my side (true, on different Reports version).
If there's another workaround, I don't know about it. I didn't even know about this one, until @ramoradba pointed it out. If you ever find it out, I hope you'll share it with us. But entering number of a page you want to paint red is simply stupid (sorry for the word, but that it is). I believe that you were upset; however, a parameter based solution is anti-solution.
I guess we came in front of the wall.
|
|
|
|
|
|