TOTAL PAGES

Dicas e truques sobre Oracle Reports Builder - modo gráfico ou modo caractere, ascii, arquivo .PRT, etc
Post Reply
ralmeida
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Posts: 6
Joined: Fri, 07 Jan 2005 9:09 am
Location: Assis/SP

All right guys !!!!


I would like to know how I can bring into a formula column the value of the total pages of the report.


Ricardo
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Creates a boilerplace and puts the following text on it:

Select all

Página &<PageNumber> de &<TotalPages>
Another way is you create a field and choose in Source it "Total Phisical Pages"
ralmeida
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Posts: 6
Joined: Fri, 07 Jan 2005 9:09 am
Location: Assis/SP

Dear Dr. Gori ...

I need to bring the value of the total pages into the formula column as I will execute calculations with this value.

Ricardo
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Take a look at this topic ... http://en.glufke.net/oracle/viewtopic.php?t=550
The guy did something like that.
ralmeida
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Posts: 6
Joined: Fri, 07 Jan 2005 9:09 am
Location: Assis/SP

This can not help me !!!!

As the report is microfilm fiscal book where each microfilm receives 175 pages, I will need to inform the quantity of pages and the amount of microfilm = (total of pages / 175).



Ricardo
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Really, this tip above does not help you, because you need to recover the tot page num.

I found a post on Metalink. I tested and it worked!

Select all

Doc ID: 	Note:130432.1 
Subject: 	HOW TO PRINT THE REPORT TOTAL PAGES ONLY AT THE LAST PAGE 
Type: 	BULLETIN 
Status: 	PUBLISHED 
	 
Content Type: 	TEXT/X-HTML 
Creation Date: 	11-DEC-2000 
Last Revision Date: 	05-DEC-2001 
 
 
SCOPE & APPLICATION 
------------------- 
This document gives a workaround to get the report total pages number 
and use it, in the format trigger of a field so that will be printed  
ONLY at the last page of the report. 
 
The problem is that you cannot refer to a field with source total_pages    
in the format trigger of another field without getting the error 'REP-730 
The following bind variable is not defined', and also there is not any build  
in function (like srw.get_page_num) to calculate the report total pages.      
 
 
 
HOW TO PRINT REPORT TOTAL PAGES AT LAST PAGE  
-------------------------------------------- 
  
1. Add in the report 2 fields :  total_pages with source 'Total Pages' and  
page_num with source 'Page Number'. 
2. Create in the database a table page_num  to store the number of pages of the  
report.  You can also add in this table another column to store the session id 
in order to insert the page numbers with a unique identifier 
for this report instance and be able to use this technique for multiple reports. 
The description of the table page_num will be: 
 Name                            Type 
 ------------------------------- ---- 
 SESSION_ID                      NUMBER(10) 
 PAGE_NUM                        NUMBER(10) 
 
(You can also use a local package variable to store the page number instead of  
inserting it in a database table). 
 
In the format trigger of the field total_pages write the following code in order 
to get the total pages of the report and insert this number in a table:      
 
function total_pagesFormatTrigger return boolean is                             
  page_num number;                                                               
  a number(3);                                                                   
begin                                                                            
  srw.get_page_num (page_num);                              
  a:= page_num; 
  insert into page_num values(global.session_id,a); 
  commit;                                                                                                                        
  return (TRUE);                                                                 
end;    
 
global.session_id comes from a package variable you have previously created in  
order to get the session id.  
 
The package specification and body is as follows: 
PACKAGE global IS 
        session_id number(10) ; 
END; 
 
PACKAGE BODY global IS 
begin 
select  sid 
into    session_id 
from    v$session 
where   audsid = userenv('sessionid') ; 
END; 
                                                                   
In the format trigger of the page_num field write the following code in order to     
retrieve the total pages from the database, compare it with the current page      
and print it if current page is equal to the last page:                                 
 
function page_numFormatTrigger return boolean is                                    
  this_page number;                                                              
  a number;                                                                      
  b number;                                                                      
begin                                                                            
  srw.get_page_num(this_page);                                                   
  a := this_page; 
  select max(page_num) into b from page_num  
  where session_id = global.session_id;                                                                
  if a = b then                                                                  
    return(TRUE);                                                               
  else                                                                           
    return(FALSE);                                                                
  end if;                                                                        
end; 
 
Finally delete the records in the page_num table after the report ends  
in the After Report Trigger: 
function AfterReport return boolean is 
begin 
  srw.do_sql('delete from page_num where session_id = ' || to_char(global.session_id)); 
  srw.do_sql('commit'); 
 return (TRUE);  
end; 
 
 
ralmeida
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Posts: 6
Joined: Fri, 07 Jan 2005 9:09 am
Location: Assis/SP

Dear Dr.



I tested with this code and still in a solution .... The big problem is that I have to bring in the first page of the report the total_pages / 175. [[99]



Ricardo
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

With this tip above, you can discover the number of total pages, applying

Select all

select max(page_num) into b from page_num 
  where session_id = global.session_id; 
to put this value on the initial page, just put this code above inside a block pl / SQL of a field any and then do so to show the value of B in the field:

Select all

srw.set_field(0, b); 
That is, Vada time the field appears on the screen , he'll get Max and show in the field!

Try it!
ralmeida
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Posts: 6
Joined: Fri, 07 Jan 2005 9:09 am
Location: Assis/SP

I was able to arrive in a solution ......


only I had to make several changes in this code ...
Thank you very much for the tip ... :! ::!::!:

: D



Ricardo
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Well, if it's not uncomfortable, how can you put on what you did?
(Type, hence the tip for someone else)

valeu
User avatar
Toad
Rank: DBA Pleno
Rank: DBA Pleno
Posts: 253
Joined: Fri, 18 Nov 2005 2:14 pm
Location: Seattle, WA
Contact:
Matheus Gonçalves
matheus.dev
twitter.com/developer__c

But Dr_Gori, I applied this example, it even returns the correct value, but only on the last page. I need this value to be shown on all pages. Only when it inserted the last value in the table (that of the effective last page), it already "created" the page. How to make the value of the last page appear in all of them? It would be possible? I'm killing me here and I do not get anywhere.
I wanted something like this:

Page 1, Displays: 01 / 175
Page 2, Displays: 02 / 175
page 3, displays: 03 / 175

Remembering that this hypothetical value 175 I get with some calculations involving the previous process (INSERT INTO Page_NUM VALUES (global.session_id, a);), so I can not use & total_logical_pages simply.

Is there anything that can be done?
User avatar
passageiromr
Rank: Estagiário Pleno
Rank: Estagiário Pleno
Posts: 7
Joined: Tue, 24 Oct 2006 10:15 am
Location: Santa Cruz do Rio Pardo
Contact:

Good morning, the tip of picking up the last page number, but I needed to pass that number by extensive in a fiscal book I'm doing, thank you.

Sincerely Eli.
User avatar
Toad
Rank: DBA Pleno
Rank: DBA Pleno
Posts: 253
Joined: Fri, 18 Nov 2005 2:14 pm
Location: Seattle, WA
Contact:
Matheus Gonçalves
matheus.dev
twitter.com/developer__c

Rafael.Steil
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 10
Joined: Mon, 09 Feb 2009 3:12 pm
Location: Sapiranga

I have the same problem as Ricardo can someone help me, with getting the total number of pages on the first page by changing the home page?
JOPA
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 58
Joined: Fri, 30 Oct 2009 9:52 am
Location: Salvador - BA
Contact:
Atenciosamente,

João Paulo A. C. do Bomfim

"Deu certo? Deixa! Funcionou? Não mexa!"

I simply got it putting 2 << Field >> in Body.

I gave a double-click on the first and, on the Object tab, in Source> From: I selected the << & logical page option >> b] Current page .

already in the second << Field >> I did the same procedure, but the selected option was << & total logical pages >> representing the Pages generated.
Page 1, Displays: 1/5
Page 2, displays: 2/5
Page 3, displays: 3/5


Success !!!

No programming was required and, this was done in Reports 2.5 here in the company.
User avatar
dr_gori
Moderador
Moderador
Posts: 5024
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Yes, but the workaround quoted above is to manipulate this information. Let's say the first page has to stay with number 20, for example. (to be attached into tax books, etc., which has to have the numbering according to the previous book) ...
JOPA
Rank: Programador Sênior
Rank: Programador Sênior
Posts: 58
Joined: Fri, 30 Oct 2009 9:52 am
Location: Salvador - BA
Contact:
Atenciosamente,

João Paulo A. C. do Bomfim

"Deu certo? Deixa! Funcionou? Não mexa!"

No problem.

I just tested here.

I gave a double click on the << Field >> from current page and there is a button titled << page numbering. .. >>.
When you click on it a new window is opened where you have a << start at: >> I changed from 1 to 20.

I did the same procedure for the second << field >>.

Success!

Page 1, displays: 20/25
Page 2, displays: 21/25
Page 3, Displays: 22/25

Remembering: Reports 2.5
ferik
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 1
Joined: Thu, 17 Dec 2009 12:03 pm
Location: LINS - SP
Fabio Erik Goncalves

Hello,

I found a code sent by dr. Gori as follows:

<<<< Start >>>>>>>>>
Doc ID: Note: 130432.1
Subject: How To Print The Report Total Pages Only At The Last Page
Type: Bulletin
Status: Published

Content Type: Type / X-HTML
Creation Date: 11-DEC-2000
Last Revision Date: 05-Dec-2001


Scope & Application
---- ---------------
This document gives a workaround to get the total pages number
and use it, in the format trigger of a field so that Will Be Printed
Only at the Last Page of the Report.

The problem is that you cannot refer to the format Trigger of Another Field Without Getting The Error 'Rep-730
The Following bind variable is not defined ', and also there is not any build
in function (like srw.get_page_num) to Calculate The Report Total Pages.


How To Print Report Total Pages at Last Page
---------------- ----------------------------

1. Add in the Report 2 Fields: Total_Pages with Source 'Total pages' and
Page_NUM WITH SOURCE 'Page NUMBER'.
2. Create in the Database to Table Page_NUM to Store The Number of Pages of the
Report. You can ALSO Add in this Table Another Column to Store The Session ID
In Order to Insert The Page Numbers With A Unique Identifier

The Description of the Table Page_NUM Will Be:
Name Type
------------------------ ------- ----
session_id Number (10)
Page_NUM Number (10)


(YOU CAN ALSO Use the Variable Package To Store The Page Number Inser]] Inserting it in a Database Table).
In The Format Trigger of the Field Total_Pages Write The Following Code in Order
To get The Total Pages of the Report and Insert This Number In Table:

Select all

function total_pagesFormatTrigger return boolean is                             
  page_num number;                                                               
  a number(3);                                                                   
begin                                                                             
  srw.get_page_num (page_num);                               
  a:= page_num;  
  insert into page_num values(global.session_id,a);  
  commit;                                                                                                                         
  return (TRUE);                                                                 
end;   

GLOBAL.SESSION_ID COMES From A Package Variable You Have Previously Created In
Order to Get The Session ID.

The Package Specification and Body is A Follows:

Select all

PACKAGE global IS  
        session_id number(10) ;  
END;  
 
PACKAGE BODY global IS  
begin  
select  sid  
into    session_id  
from    v$session  
where   audsid = userenv('sessionid') ;  
END; 
In The Format Trigger Of The Page_Num Field Write The Following Code in Order to
Retrieve The Total Pages from The Database, Compare IT with the Current Page
and Print IF Current Page:

Select all

function page_numFormatTrigger return boolean is                                     
  this_page number;                                                               
  a number;                                                                       
  b number;                                                                       
begin                                                                             
  srw.get_page_num(this_page);                                                   
  a := this_page;  
  select max(page_num) into b from page_num  
  where session_id = global.session_id;                                                                 
  if a = b then                                                                   
    return(TRUE);                                                               
  else                                                                           
    return(FALSE);                                                                 
  end if;                                                                         
end; 
finally delete the records in the page_num table after the report Ends
In the After Report Trigger:

Select all

function AfterReport return boolean is  
begin  
  srw.do_sql('delete from page_num where session_id = ' || to_char(global.session_id));  
  srw.do_sql('commit');  
 return (TRUE);  
end;
<<<< End >> >>>>>>>

But for what I am noticing the Field Page_NUM is running before the Trigger of the Field Total_pages, that is when I pick up the Select Max (page_num) I get as Return null, will this problem been related to execution hierarchy? Can you manipulate this, will anyone know what I'm doing wrong?

I thanked the attention.

Abraco
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 9 guests