Hi
I have designed a report on Invoice details and grouped by Invoice Numbers
and also applied page break on this group. I need to reset page numbers on
each Invoice number.
Is this possible?
Anyone know how to do this?
I am using SQL Server 2000 Reporting Services.
Thnx
DimpuHi Dimpu,
Not supported in RS 2000, but there is a workaround using a little code
- check out Chris Hay's RS Sleazy Hacks BLOG entry at
http://blogs.msdn.com/chrishays/archive/2006/01/05/ResetPageNumberOnGroup.aspx
It works great!
MattA
www.reportarchitex.com|||Hi Matt
It worked! Many thnx for your valuable information.
Regards
dimpu
"MattA" wrote:
> Hi Dimpu,
> Not supported in RS 2000, but there is a workaround using a little code
> - check out Chris Hay's RS Sleazy Hacks BLOG entry at
> http://blogs.msdn.com/chrishays/archive/2006/01/05/ResetPageNumberOnGroup.aspx
>
> It works great!
> MattA
> www.reportarchitex.com
>
Showing posts with label break. Show all posts
Showing posts with label break. Show all posts
Wednesday, March 28, 2012
Monday, March 26, 2012
Resetting @@Fetch_Status
Hi:
if I run a loop like so...
While @.@.FETCH_STATUS = 0
BEGIN
..Some code
END
It will break out of loop when @.@.FETCH_STATUS = -1. The problem is if I try
to run it again, @.@.FETCH_STATUS will remain at -1 and loop in never entered.
I have to close connection to get it to reset. How do I force it to reset
so I can work with it repeatedly in Query Analyzer?
Thanks,
CharlieCharlie@.CBFC wrote:
> Hi:
> if I run a loop like so...
> While @.@.FETCH_STATUS = 0
> BEGIN
> ...Some code
> END
>
> It will break out of loop when @.@.FETCH_STATUS = -1. The problem is
> if I try to run it again, @.@.FETCH_STATUS will remain at -1 and loop
> in never entered. I have to close connection to get it to reset. How
> do I force it to reset so I can work with it repeatedly in Query
> Analyzer?
>
You need to perform a FETCH that does not result in a non-zero status.
Of course, some will say that you should stop using cursors ... ;-)
HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.|||On Mon, 14 Nov 2005 16:26:26 -0500, Charlie@.CBFC wrote:
>Hi:
>if I run a loop like so...
>While @.@.FETCH_STATUS = 0
> BEGIN
> ...Some code
> END
>
>It will break out of loop when @.@.FETCH_STATUS = -1. The problem is if I tr
y
>to run it again, @.@.FETCH_STATUS will remain at -1 and loop in never entered
.
>I have to close connection to get it to reset. How do I force it to reset
>so I can work with it repeatedly in Query Analyzer?
Hi Charlie,
The generic outline (in pseudo-code) for consuming a trigger is:
-- Declare and open the curor
-- Fetch first row
WHILE @.@.FETCH_STATUS = 0
BEGIN
-- Process data from one row
-- Fetch next row
END -- repeats until FETCH_STATUS <> 0
-- Close and deallocate the cursor
Of course, some will say that you should stop using cursors ... ;-)
(and I would agree!!!)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||Hugo Kornelis (hugo@.pe_NO_rFact.in_SPAM_fo) writes:
> The generic outline (in pseudo-code) for consuming a trigger is:
Consuming what? Haven't your mummy told you not to be up that late
at night? Or least stop consuming? :-)
> -- Declare and open the curor
> -- Fetch first row
> WHILE @.@.FETCH_STATUS = 0
> BEGIN
> -- Process data from one row
> -- Fetch next row
> END -- repeats until FETCH_STATUS <> 0
> -- Close and deallocate the cursor
Nah, this is the way should it, in my opinion:
DECLARE cur INSENSITIVE CURSOR FOR
SELECT ...
SELECT @.err = @.@.error IF @.err <> 0 BEGIN DEALLOCATE cur RETURN END
OPEN cur
WHILE 1 = 1
BEGIN
FETCH cur INTO ...
IF @.@.fetch_status <> 0
BREAK
-- Do stuff
END
DEALLOCATE cur
The point is that with only one FETCH statement, and which is close
to the cursor declaration, you don't run the risk of adding one more
column to the cursor, updating the first FETCH, but forgetting the
second.
And the cursor should be INSENSITIVE to avoid the nasty pitfalls of
keyset-driven cursors (which I still have not understood). FAST_FORWARD
or STATIC are probably OK to, but INSENSITIVE is ANSI.
> Of course, some will say that you should stop using cursors ... ;-)
> (and I would agree!!!)
Me too!
Then again, cursors are perfectly acceptable in some situations. And if
you have decided that you will iterate - a cursor is the best choice.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||I'm curious ... I use cursors all the time. Why would I want to stop using c
ursor? And
what would I use to replace the cursor functionality?
On Mon, 14 Nov 2005 23:40:08 +0000 (UTC), Erland Sommarskog <esquel@.sommarsk
og.se> wrote:
>Hugo Kornelis (hugo@.pe_NO_rFact.in_SPAM_fo) writes:
>Consuming what? Haven't your mummy told you not to be up that late
>at night? Or least stop consuming? :-)
>
>Nah, this is the way should it, in my opinion:
> DECLARE cur INSENSITIVE CURSOR FOR
> SELECT ...
> SELECT @.err = @.@.error IF @.err <> 0 BEGIN DEALLOCATE cur RETURN END
> OPEN cur
> WHILE 1 = 1
> BEGIN
> FETCH cur INTO ...
> IF @.@.fetch_status <> 0
> BREAK
> -- Do stuff
> END
> DEALLOCATE cur
>The point is that with only one FETCH statement, and which is close
>to the cursor declaration, you don't run the risk of adding one more
>column to the cursor, updating the first FETCH, but forgetting the
>second.
>And the cursor should be INSENSITIVE to avoid the nasty pitfalls of
>keyset-driven cursors (which I still have not understood). FAST_FORWARD
>or STATIC are probably OK to, but INSENSITIVE is ANSI.
>
>Me too!
>Then again, cursors are perfectly acceptable in some situations. And if
>you have decided that you will iterate - a cursor is the best choice.|||Gaetan <someone@.somewhere.com> wrote:
>I'm curious ... I use cursors all the time. Why would I want to stop using
cursor? And
>what would I use to replace the cursor functionality?
Cursors allow row-at-a-time processing. SQL Server is not written for
row-at-a-time processing, and so cursors are, in general, inefficient.
SQL works best when used relationally, everything-at-once rather than
row-at-a-time. Cursors are invaluable, but should be considered a
last resort.
Row-at-a-time cursors look familiar to programmers who are used to
conventional programming languages, and often cursors are used by such
programmers as the only apparent (to them) way to get things done.
They are used as a first approach, rather than a last resort - a
substitute for relational thinking.
Often we find that a problem which has been solved by a cursor could
have been solved relationally, without a cursor. It is not uncommon
for the relational approach to outperform the cursor significantly -
we can be talking about an order of magnitude.
All of which is a broad generalization, and of course there are
exceptions. But like many such generalizations, the exceptions are
far fewer than some would have us believe.
Roy|||I understand what you are saying but I fail to understand how else I could u
se a
relational processing to perform a row-at-a-time process. For example, in a
SP I need to
apply some business logic on rows of a table matching specific criterias and
return the
output;
Table XYZ -> CURSOR -> Business processing on each row -> insert into temp t
able -> select
* from temp table
How could this type of processing be performed without the use of a CURSOR?
If I could get
an order of magnitude performance gain, you bet that I will change a few sto
red procedures
right away.
Thanks.
On Mon, 14 Nov 2005 22:43:17 -0500, Roy Harvey <roy_harvey@.snet.net> wrote:
>Gaetan <someone@.somewhere.com> wrote:
>
>Cursors allow row-at-a-time processing. SQL Server is not written for
>row-at-a-time processing, and so cursors are, in general, inefficient.
>SQL works best when used relationally, everything-at-once rather than
>row-at-a-time. Cursors are invaluable, but should be considered a
>last resort.
>Row-at-a-time cursors look familiar to programmers who are used to
>conventional programming languages, and often cursors are used by such
>programmers as the only apparent (to them) way to get things done.
>They are used as a first approach, rather than a last resort - a
>substitute for relational thinking.
>Often we find that a problem which has been solved by a cursor could
>have been solved relationally, without a cursor. It is not uncommon
>for the relational approach to outperform the cursor significantly -
>we can be talking about an order of magnitude.
>All of which is a broad generalization, and of course there are
>exceptions. But like many such generalizations, the exceptions are
>far fewer than some would have us believe.
>Roy|||Well, what is the business processing you are attempting to do? Is it
not something that can be applied to all of the rows at once?
Stu|||Gaetan (someone@.somewhere.com) writes:
> I understand what you are saying but I fail to understand how else I
> could use a relational processing to perform a row-at-a-time process.
> For example, in a SP I need to apply some business logic on rows of a
> table matching specific criterias and return the output;
> Table XYZ -> CURSOR -> Business processing on each row -> insert into
> temp table -> select * from temp table
> How could this type of processing be performed without the use of a
> CURSOR? If I could get an order of magnitude performance gain, you bet
> that I will change a few stored procedures right away.
That depends on the business processing to apply. Admittedly, in some
cases you can only work with it one at time, but say that the business
processing is "increase the salary with 2% for all employees", there's
obviously no need for a cursor here. The rules for the salary increase
may be more complex, but could very well still be implementable in a
single UPDATE statement. But say that for each employee you need to
call some external program to get the salary increase, at this point you
may have to resort to a cursor.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Gaetan <someone@.somewhere.com> wrote:
>I understand what you are saying but I fail to understand how else I could
use a
>relational processing to perform a row-at-a-time process. For example, in a
SP I need to
>apply some business logic on rows of a table matching specific criterias an
d return the
>output;
>Table XYZ -> CURSOR -> Business processing on each row -> insert into temp
table -> select
>* from temp table
>How could this type of processing be performed without the use of a CURSOR?
If I could get
>an order of magnitude performance gain, you bet that I will change a few st
ored procedures
>right away.
>Thanks.
The question is whether "Business processing on each row" can be done
relationally. Perhaps it can't, but I would not make that judgement
without knowing a lot more about that business processing. If you
care to share some of the requirements someone might have some
thoughts to share on whether they can be handled relationally.
One clear-cut case where cursors were required comes to mind, where
transactions had to be applied in strict sequence.
Roy
if I run a loop like so...
While @.@.FETCH_STATUS = 0
BEGIN
..Some code
END
It will break out of loop when @.@.FETCH_STATUS = -1. The problem is if I try
to run it again, @.@.FETCH_STATUS will remain at -1 and loop in never entered.
I have to close connection to get it to reset. How do I force it to reset
so I can work with it repeatedly in Query Analyzer?
Thanks,
CharlieCharlie@.CBFC wrote:
> Hi:
> if I run a loop like so...
> While @.@.FETCH_STATUS = 0
> BEGIN
> ...Some code
> END
>
> It will break out of loop when @.@.FETCH_STATUS = -1. The problem is
> if I try to run it again, @.@.FETCH_STATUS will remain at -1 and loop
> in never entered. I have to close connection to get it to reset. How
> do I force it to reset so I can work with it repeatedly in Query
> Analyzer?
>
You need to perform a FETCH that does not result in a non-zero status.
Of course, some will say that you should stop using cursors ... ;-)
HTH,
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.|||On Mon, 14 Nov 2005 16:26:26 -0500, Charlie@.CBFC wrote:
>Hi:
>if I run a loop like so...
>While @.@.FETCH_STATUS = 0
> BEGIN
> ...Some code
> END
>
>It will break out of loop when @.@.FETCH_STATUS = -1. The problem is if I tr
y
>to run it again, @.@.FETCH_STATUS will remain at -1 and loop in never entered
.
>I have to close connection to get it to reset. How do I force it to reset
>so I can work with it repeatedly in Query Analyzer?
Hi Charlie,
The generic outline (in pseudo-code) for consuming a trigger is:
-- Declare and open the curor
-- Fetch first row
WHILE @.@.FETCH_STATUS = 0
BEGIN
-- Process data from one row
-- Fetch next row
END -- repeats until FETCH_STATUS <> 0
-- Close and deallocate the cursor
Of course, some will say that you should stop using cursors ... ;-)
(and I would agree!!!)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)|||Hugo Kornelis (hugo@.pe_NO_rFact.in_SPAM_fo) writes:
> The generic outline (in pseudo-code) for consuming a trigger is:
Consuming what? Haven't your mummy told you not to be up that late
at night? Or least stop consuming? :-)
> -- Declare and open the curor
> -- Fetch first row
> WHILE @.@.FETCH_STATUS = 0
> BEGIN
> -- Process data from one row
> -- Fetch next row
> END -- repeats until FETCH_STATUS <> 0
> -- Close and deallocate the cursor
Nah, this is the way should it, in my opinion:
DECLARE cur INSENSITIVE CURSOR FOR
SELECT ...
SELECT @.err = @.@.error IF @.err <> 0 BEGIN DEALLOCATE cur RETURN END
OPEN cur
WHILE 1 = 1
BEGIN
FETCH cur INTO ...
IF @.@.fetch_status <> 0
BREAK
-- Do stuff
END
DEALLOCATE cur
The point is that with only one FETCH statement, and which is close
to the cursor declaration, you don't run the risk of adding one more
column to the cursor, updating the first FETCH, but forgetting the
second.
And the cursor should be INSENSITIVE to avoid the nasty pitfalls of
keyset-driven cursors (which I still have not understood). FAST_FORWARD
or STATIC are probably OK to, but INSENSITIVE is ANSI.
> Of course, some will say that you should stop using cursors ... ;-)
> (and I would agree!!!)
Me too!
Then again, cursors are perfectly acceptable in some situations. And if
you have decided that you will iterate - a cursor is the best choice.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||I'm curious ... I use cursors all the time. Why would I want to stop using c
ursor? And
what would I use to replace the cursor functionality?
On Mon, 14 Nov 2005 23:40:08 +0000 (UTC), Erland Sommarskog <esquel@.sommarsk
og.se> wrote:
>Hugo Kornelis (hugo@.pe_NO_rFact.in_SPAM_fo) writes:
>Consuming what? Haven't your mummy told you not to be up that late
>at night? Or least stop consuming? :-)
>
>Nah, this is the way should it, in my opinion:
> DECLARE cur INSENSITIVE CURSOR FOR
> SELECT ...
> SELECT @.err = @.@.error IF @.err <> 0 BEGIN DEALLOCATE cur RETURN END
> OPEN cur
> WHILE 1 = 1
> BEGIN
> FETCH cur INTO ...
> IF @.@.fetch_status <> 0
> BREAK
> -- Do stuff
> END
> DEALLOCATE cur
>The point is that with only one FETCH statement, and which is close
>to the cursor declaration, you don't run the risk of adding one more
>column to the cursor, updating the first FETCH, but forgetting the
>second.
>And the cursor should be INSENSITIVE to avoid the nasty pitfalls of
>keyset-driven cursors (which I still have not understood). FAST_FORWARD
>or STATIC are probably OK to, but INSENSITIVE is ANSI.
>
>Me too!
>Then again, cursors are perfectly acceptable in some situations. And if
>you have decided that you will iterate - a cursor is the best choice.|||Gaetan <someone@.somewhere.com> wrote:
>I'm curious ... I use cursors all the time. Why would I want to stop using
cursor? And
>what would I use to replace the cursor functionality?
Cursors allow row-at-a-time processing. SQL Server is not written for
row-at-a-time processing, and so cursors are, in general, inefficient.
SQL works best when used relationally, everything-at-once rather than
row-at-a-time. Cursors are invaluable, but should be considered a
last resort.
Row-at-a-time cursors look familiar to programmers who are used to
conventional programming languages, and often cursors are used by such
programmers as the only apparent (to them) way to get things done.
They are used as a first approach, rather than a last resort - a
substitute for relational thinking.
Often we find that a problem which has been solved by a cursor could
have been solved relationally, without a cursor. It is not uncommon
for the relational approach to outperform the cursor significantly -
we can be talking about an order of magnitude.
All of which is a broad generalization, and of course there are
exceptions. But like many such generalizations, the exceptions are
far fewer than some would have us believe.
Roy|||I understand what you are saying but I fail to understand how else I could u
se a
relational processing to perform a row-at-a-time process. For example, in a
SP I need to
apply some business logic on rows of a table matching specific criterias and
return the
output;
Table XYZ -> CURSOR -> Business processing on each row -> insert into temp t
able -> select
* from temp table
How could this type of processing be performed without the use of a CURSOR?
If I could get
an order of magnitude performance gain, you bet that I will change a few sto
red procedures
right away.
Thanks.
On Mon, 14 Nov 2005 22:43:17 -0500, Roy Harvey <roy_harvey@.snet.net> wrote:
>Gaetan <someone@.somewhere.com> wrote:
>
>Cursors allow row-at-a-time processing. SQL Server is not written for
>row-at-a-time processing, and so cursors are, in general, inefficient.
>SQL works best when used relationally, everything-at-once rather than
>row-at-a-time. Cursors are invaluable, but should be considered a
>last resort.
>Row-at-a-time cursors look familiar to programmers who are used to
>conventional programming languages, and often cursors are used by such
>programmers as the only apparent (to them) way to get things done.
>They are used as a first approach, rather than a last resort - a
>substitute for relational thinking.
>Often we find that a problem which has been solved by a cursor could
>have been solved relationally, without a cursor. It is not uncommon
>for the relational approach to outperform the cursor significantly -
>we can be talking about an order of magnitude.
>All of which is a broad generalization, and of course there are
>exceptions. But like many such generalizations, the exceptions are
>far fewer than some would have us believe.
>Roy|||Well, what is the business processing you are attempting to do? Is it
not something that can be applied to all of the rows at once?
Stu|||Gaetan (someone@.somewhere.com) writes:
> I understand what you are saying but I fail to understand how else I
> could use a relational processing to perform a row-at-a-time process.
> For example, in a SP I need to apply some business logic on rows of a
> table matching specific criterias and return the output;
> Table XYZ -> CURSOR -> Business processing on each row -> insert into
> temp table -> select * from temp table
> How could this type of processing be performed without the use of a
> CURSOR? If I could get an order of magnitude performance gain, you bet
> that I will change a few stored procedures right away.
That depends on the business processing to apply. Admittedly, in some
cases you can only work with it one at time, but say that the business
processing is "increase the salary with 2% for all employees", there's
obviously no need for a cursor here. The rules for the salary increase
may be more complex, but could very well still be implementable in a
single UPDATE statement. But say that for each employee you need to
call some external program to get the salary increase, at this point you
may have to resort to a cursor.
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Gaetan <someone@.somewhere.com> wrote:
>I understand what you are saying but I fail to understand how else I could
use a
>relational processing to perform a row-at-a-time process. For example, in a
SP I need to
>apply some business logic on rows of a table matching specific criterias an
d return the
>output;
>Table XYZ -> CURSOR -> Business processing on each row -> insert into temp
table -> select
>* from temp table
>How could this type of processing be performed without the use of a CURSOR?
If I could get
>an order of magnitude performance gain, you bet that I will change a few st
ored procedures
>right away.
>Thanks.
The question is whether "Business processing on each row" can be done
relationally. Perhaps it can't, but I would not make that judgement
without knowing a lot more about that business processing. If you
care to share some of the requirements someone might have some
thoughts to share on whether they can be handled relationally.
One clear-cut case where cursors were required comes to mind, where
transactions had to be applied in strict sequence.
Roy
Friday, March 23, 2012
Reset Page Numbering Total
I am wanting to reset the page number on the break of each group.
For example
Group A - 3 pages
Group B - 4 pages
So for group B on the 4th page it will start with 1, using the following
code this does this fine
Shared offset As Integer
Public Function GetPN(reset As Boolean, pagenumber As Integer) As Integer
If reset
offset = pagenumber - 1
End If
Return pagenumber - offset
End Function
I am wanting to do this for the total of the pages as well so for example
page 4 would show as 1 of 4 instead of 1 of 7
How do I get this working for the total pages as well as the individual pagesI have the same problem, did you come up with any solution?
"Mark Stanley" wrote:
> I am wanting to reset the page number on the break of each group.
> For example
> Group A - 3 pages
> Group B - 4 pages
> So for group B on the 4th page it will start with 1, using the following
> code this does this fine
> Shared offset As Integer
> Public Function GetPN(reset As Boolean, pagenumber As Integer) As Integer
> If reset
> offset = pagenumber - 1
> End If
> Return pagenumber - offset
> End Function
> I am wanting to do this for the total of the pages as well so for example
> page 4 would show as 1 of 4 instead of 1 of 7
> How do I get this working for the total pages as well as the individual pages|||Jim,
See my earlier posting in this thread.
It's not a simple solution but it might help.
Chris
JIM.H. wrote:
> I have the same problem, did you come up with any solution?
> "Mark Stanley" wrote:
> > I am wanting to reset the page number on the break of each group.
> >
> > For example
> >
> > Group A - 3 pages
> > Group B - 4 pages
> >
> > So for group B on the 4th page it will start with 1, using the
> > following code this does this fine
> >
> > Shared offset As Integer
> >
> > Public Function GetPN(reset As Boolean, pagenumber As Integer) As
> > Integer If reset
> > offset = pagenumber - 1
> > End If
> > Return pagenumber - offset
> > End Function
> >
> > I am wanting to do this for the total of the pages as well so for
> > example page 4 would show as 1 of 4 instead of 1 of 7
> >
> > How do I get this working for the total pages as well as the
> > individual pages|||Hi Chris,
Did you mean you attached something in the previous message, I am using web
interface and do not know how to see attachments.
"Chris McGuigan" wrote:
> Jim,
> See my earlier posting in this thread.
> It's not a simple solution but it might help.
> Chris
>
> JIM.H. wrote:
> > I have the same problem, did you come up with any solution?
> >
> > "Mark Stanley" wrote:
> >
> > > I am wanting to reset the page number on the break of each group.
> > >
> > > For example
> > >
> > > Group A - 3 pages
> > > Group B - 4 pages
> > >
> > > So for group B on the 4th page it will start with 1, using the
> > > following code this does this fine
> > >
> > > Shared offset As Integer
> > >
> > > Public Function GetPN(reset As Boolean, pagenumber As Integer) As
> > > Integer If reset
> > > offset = pagenumber - 1
> > > End If
> > > Return pagenumber - offset
> > > End Function
> > >
> > > I am wanting to do this for the total of the pages as well so for
> > > example page 4 would show as 1 of 4 instead of 1 of 7
> > >
> > > How do I get this working for the total pages as well as the
> > > individual pages
>|||Jim,
Here is the contents of the file;
----
Unfortunately, there's currently no good way to build a table of
contents.
And even adding defined execution order isn't going to help, since
pagination happens as a completely separate step from the rest of the
report. This is because you can request the same report with different
page
size/margin settings (and even an entirely different rendering target,
which
could radically change pagination). Under normal circumstances, we don't
want to force reexecution of the entire report just because you change
your
margins.
To handle table of contents type operations, we're going to (eventually)
have to implement an entirely new mode wherein we know that the body of
the
report contains references to page numbers, which will force the entire
report to reexecute if pagination information changes.
In the mean time, there's no general solution for the table of contents
problem.
But... Since you're doing this in a batch once a month, you may not
need a
fully general solution.
Without further ado, here's Sleazy Hack #792 ("Simulating Table of
Contents
in Batch Reporting Scenarios"):
1. Write a custom assembly containing a class that can write rows to a
TableOfContents table in your database.
Have shared methods for both initializing the TOC and writing a new
row
to the TOC.
Note: Don't forget to give it database permissions in the CAS file
when
you deploy it to your server.
See the documentation for details on custom assemblies.
2. In the Code section of the report, call the TOC initialization in
the
OnInit() event.
3. At the start of each section you want to appear in your TOC, put a
hidden textbox that contains the label you want to appear in your TOC.
4. In the page header, put a hidden textbox with something like the
following expression:
=Code.MyTOCClass.AddToTOC(Globals.PageNumber,ReportItems!Textbox1.Value
& ReportItems!Textbox2.Value & ReportItems!Textbox3.Value)
Texbox1, Textbox2 and Textbox3 are the names of the hidden textboxes
from step 3 (since only one will appear on any given page, the rest
will be
empty)
5. Add a dataset to your report which selects from the TableOfContents
table
6. Display the results of the TOC data set in a table at the end of
your
report*
7. Run the report twice. The first time will initialize the TOC. The
second time will use the values from the previous run.
* If you want it at the beginning, you'll either need to run the report
three times (the first to get some rows into the TOC table, the second
to
get the numbers populated correctly and the third to use those numbers)
or
you'll need to make sure the TOC table has the right number of rows to
begin
with (perhaps by not emptying it from the previous month) otherwise your
page numbers will be incorrect due to the TOC pushing things around.
This
isn't an issue if your TOC is only one page long and has PageBreakAtEnd,
however.
JIM.H. wrote:
> Hi Chris,
> Did you mean you attached something in the previous message, I am
> using web interface and do not know how to see attachments.
> "Chris McGuigan" wrote:
> > Jim,
> > See my earlier posting in this thread.
> > It's not a simple solution but it might help.
> >
> > Chris
> >
> >
> > JIM.H. wrote:
> >
> > > I have the same problem, did you come up with any solution?
> > >
> > > "Mark Stanley" wrote:
> > >
> > > > I am wanting to reset the page number on the break of each
> > > > group.
> > > >
> > > > For example
> > > >
> > > > Group A - 3 pages
> > > > Group B - 4 pages
> > > >
> > > > So for group B on the 4th page it will start with 1, using the
> > > > following code this does this fine
> > > >
> > > > Shared offset As Integer
> > > >
> > > > Public Function GetPN(reset As Boolean, pagenumber As Integer)
> > > > As Integer If reset
> > > > offset = pagenumber - 1
> > > > End If
> > > > Return pagenumber - offset
> > > > End Function
> > > >
> > > > I am wanting to do this for the total of the pages as well so
> > > > for example page 4 would show as 1 of 4 instead of 1 of 7
> > > >
> > > > How do I get this working for the total pages as well as the
> > > > individual pages
> >
> >|||Yes there was an attachment. You'll need a "proper" newsreader - I
recommend XanaNews, which can be downloaded at
http://www.wilsonc.demon.co.uk/d9xananews.htm
I've put the contents in another post for you.
Chris
JIM.H. wrote:
> Hi Chris,
> Did you mean you attached something in the previous message, I am
> using web interface and do not know how to see attachments.
> "Chris McGuigan" wrote:
> > Jim,
> > See my earlier posting in this thread.
> > It's not a simple solution but it might help.
> >
> > Chris
> >
> >
> > JIM.H. wrote:
> >
> > > I have the same problem, did you come up with any solution?
> > >
> > > "Mark Stanley" wrote:
> > >
> > > > I am wanting to reset the page number on the break of each
> > > > group.
> > > >
> > > > For example
> > > >
> > > > Group A - 3 pages
> > > > Group B - 4 pages
> > > >
> > > > So for group B on the 4th page it will start with 1, using the
> > > > following code this does this fine
> > > >
> > > > Shared offset As Integer
> > > >
> > > > Public Function GetPN(reset As Boolean, pagenumber As Integer)
> > > > As Integer If reset
> > > > offset = pagenumber - 1
> > > > End If
> > > > Return pagenumber - offset
> > > > End Function
> > > >
> > > > I am wanting to do this for the total of the pages as well so
> > > > for example page 4 would show as 1 of 4 instead of 1 of 7
> > > >
> > > > How do I get this working for the total pages as well as the
> > > > individual pages
> >
> >
For example
Group A - 3 pages
Group B - 4 pages
So for group B on the 4th page it will start with 1, using the following
code this does this fine
Shared offset As Integer
Public Function GetPN(reset As Boolean, pagenumber As Integer) As Integer
If reset
offset = pagenumber - 1
End If
Return pagenumber - offset
End Function
I am wanting to do this for the total of the pages as well so for example
page 4 would show as 1 of 4 instead of 1 of 7
How do I get this working for the total pages as well as the individual pagesI have the same problem, did you come up with any solution?
"Mark Stanley" wrote:
> I am wanting to reset the page number on the break of each group.
> For example
> Group A - 3 pages
> Group B - 4 pages
> So for group B on the 4th page it will start with 1, using the following
> code this does this fine
> Shared offset As Integer
> Public Function GetPN(reset As Boolean, pagenumber As Integer) As Integer
> If reset
> offset = pagenumber - 1
> End If
> Return pagenumber - offset
> End Function
> I am wanting to do this for the total of the pages as well so for example
> page 4 would show as 1 of 4 instead of 1 of 7
> How do I get this working for the total pages as well as the individual pages|||Jim,
See my earlier posting in this thread.
It's not a simple solution but it might help.
Chris
JIM.H. wrote:
> I have the same problem, did you come up with any solution?
> "Mark Stanley" wrote:
> > I am wanting to reset the page number on the break of each group.
> >
> > For example
> >
> > Group A - 3 pages
> > Group B - 4 pages
> >
> > So for group B on the 4th page it will start with 1, using the
> > following code this does this fine
> >
> > Shared offset As Integer
> >
> > Public Function GetPN(reset As Boolean, pagenumber As Integer) As
> > Integer If reset
> > offset = pagenumber - 1
> > End If
> > Return pagenumber - offset
> > End Function
> >
> > I am wanting to do this for the total of the pages as well so for
> > example page 4 would show as 1 of 4 instead of 1 of 7
> >
> > How do I get this working for the total pages as well as the
> > individual pages|||Hi Chris,
Did you mean you attached something in the previous message, I am using web
interface and do not know how to see attachments.
"Chris McGuigan" wrote:
> Jim,
> See my earlier posting in this thread.
> It's not a simple solution but it might help.
> Chris
>
> JIM.H. wrote:
> > I have the same problem, did you come up with any solution?
> >
> > "Mark Stanley" wrote:
> >
> > > I am wanting to reset the page number on the break of each group.
> > >
> > > For example
> > >
> > > Group A - 3 pages
> > > Group B - 4 pages
> > >
> > > So for group B on the 4th page it will start with 1, using the
> > > following code this does this fine
> > >
> > > Shared offset As Integer
> > >
> > > Public Function GetPN(reset As Boolean, pagenumber As Integer) As
> > > Integer If reset
> > > offset = pagenumber - 1
> > > End If
> > > Return pagenumber - offset
> > > End Function
> > >
> > > I am wanting to do this for the total of the pages as well so for
> > > example page 4 would show as 1 of 4 instead of 1 of 7
> > >
> > > How do I get this working for the total pages as well as the
> > > individual pages
>|||Jim,
Here is the contents of the file;
----
Unfortunately, there's currently no good way to build a table of
contents.
And even adding defined execution order isn't going to help, since
pagination happens as a completely separate step from the rest of the
report. This is because you can request the same report with different
page
size/margin settings (and even an entirely different rendering target,
which
could radically change pagination). Under normal circumstances, we don't
want to force reexecution of the entire report just because you change
your
margins.
To handle table of contents type operations, we're going to (eventually)
have to implement an entirely new mode wherein we know that the body of
the
report contains references to page numbers, which will force the entire
report to reexecute if pagination information changes.
In the mean time, there's no general solution for the table of contents
problem.
But... Since you're doing this in a batch once a month, you may not
need a
fully general solution.
Without further ado, here's Sleazy Hack #792 ("Simulating Table of
Contents
in Batch Reporting Scenarios"):
1. Write a custom assembly containing a class that can write rows to a
TableOfContents table in your database.
Have shared methods for both initializing the TOC and writing a new
row
to the TOC.
Note: Don't forget to give it database permissions in the CAS file
when
you deploy it to your server.
See the documentation for details on custom assemblies.
2. In the Code section of the report, call the TOC initialization in
the
OnInit() event.
3. At the start of each section you want to appear in your TOC, put a
hidden textbox that contains the label you want to appear in your TOC.
4. In the page header, put a hidden textbox with something like the
following expression:
=Code.MyTOCClass.AddToTOC(Globals.PageNumber,ReportItems!Textbox1.Value
& ReportItems!Textbox2.Value & ReportItems!Textbox3.Value)
Texbox1, Textbox2 and Textbox3 are the names of the hidden textboxes
from step 3 (since only one will appear on any given page, the rest
will be
empty)
5. Add a dataset to your report which selects from the TableOfContents
table
6. Display the results of the TOC data set in a table at the end of
your
report*
7. Run the report twice. The first time will initialize the TOC. The
second time will use the values from the previous run.
* If you want it at the beginning, you'll either need to run the report
three times (the first to get some rows into the TOC table, the second
to
get the numbers populated correctly and the third to use those numbers)
or
you'll need to make sure the TOC table has the right number of rows to
begin
with (perhaps by not emptying it from the previous month) otherwise your
page numbers will be incorrect due to the TOC pushing things around.
This
isn't an issue if your TOC is only one page long and has PageBreakAtEnd,
however.
JIM.H. wrote:
> Hi Chris,
> Did you mean you attached something in the previous message, I am
> using web interface and do not know how to see attachments.
> "Chris McGuigan" wrote:
> > Jim,
> > See my earlier posting in this thread.
> > It's not a simple solution but it might help.
> >
> > Chris
> >
> >
> > JIM.H. wrote:
> >
> > > I have the same problem, did you come up with any solution?
> > >
> > > "Mark Stanley" wrote:
> > >
> > > > I am wanting to reset the page number on the break of each
> > > > group.
> > > >
> > > > For example
> > > >
> > > > Group A - 3 pages
> > > > Group B - 4 pages
> > > >
> > > > So for group B on the 4th page it will start with 1, using the
> > > > following code this does this fine
> > > >
> > > > Shared offset As Integer
> > > >
> > > > Public Function GetPN(reset As Boolean, pagenumber As Integer)
> > > > As Integer If reset
> > > > offset = pagenumber - 1
> > > > End If
> > > > Return pagenumber - offset
> > > > End Function
> > > >
> > > > I am wanting to do this for the total of the pages as well so
> > > > for example page 4 would show as 1 of 4 instead of 1 of 7
> > > >
> > > > How do I get this working for the total pages as well as the
> > > > individual pages
> >
> >|||Yes there was an attachment. You'll need a "proper" newsreader - I
recommend XanaNews, which can be downloaded at
http://www.wilsonc.demon.co.uk/d9xananews.htm
I've put the contents in another post for you.
Chris
JIM.H. wrote:
> Hi Chris,
> Did you mean you attached something in the previous message, I am
> using web interface and do not know how to see attachments.
> "Chris McGuigan" wrote:
> > Jim,
> > See my earlier posting in this thread.
> > It's not a simple solution but it might help.
> >
> > Chris
> >
> >
> > JIM.H. wrote:
> >
> > > I have the same problem, did you come up with any solution?
> > >
> > > "Mark Stanley" wrote:
> > >
> > > > I am wanting to reset the page number on the break of each
> > > > group.
> > > >
> > > > For example
> > > >
> > > > Group A - 3 pages
> > > > Group B - 4 pages
> > > >
> > > > So for group B on the 4th page it will start with 1, using the
> > > > following code this does this fine
> > > >
> > > > Shared offset As Integer
> > > >
> > > > Public Function GetPN(reset As Boolean, pagenumber As Integer)
> > > > As Integer If reset
> > > > offset = pagenumber - 1
> > > > End If
> > > > Return pagenumber - offset
> > > > End Function
> > > >
> > > > I am wanting to do this for the total of the pages as well so
> > > > for example page 4 would show as 1 of 4 instead of 1 of 7
> > > >
> > > > How do I get this working for the total pages as well as the
> > > > individual pages
> >
> >
Friday, March 9, 2012
REQ: Help needed with extracting SP_WHO data
I need to be able to break down sp_who and pull the count of the BLK
column when it's greater than 0.
any assistance is appreciated."BobMarley" <brianh*REMOVEFOREMAIL*@.conterra.com> wrote in message
news:17l9tvg0c7vkiid1g17oatrd1ch0vio0c5@.4ax.com...
> I need to be able to break down sp_who and pull the count of the BLK
> column when it's greater than 0.
> any assistance is appreciated.
>
CREATE TABLE #sp_who (
spid smallint NOT NULL ,
ecid smallint NOT NULL ,
status nchar (30) NOT NULL ,
loginame nchar (128) NOT NULL ,
hostname nchar (128) NOT NULL ,
blk char(5),
dbname nvarchar(128),
cmd nchar (16) NOT NULL)
insert into #sp_who exec sp_who
select * from #sp_who
where blk > 0
drop table #sp_who
--David|||select * from master..sysprocesses where blk > 0?
see
http://www.nigelrivett.net/sp_nrSpidByStatus.html
Nigel Rivett
www.nigelrivett.net
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
column when it's greater than 0.
any assistance is appreciated."BobMarley" <brianh*REMOVEFOREMAIL*@.conterra.com> wrote in message
news:17l9tvg0c7vkiid1g17oatrd1ch0vio0c5@.4ax.com...
> I need to be able to break down sp_who and pull the count of the BLK
> column when it's greater than 0.
> any assistance is appreciated.
>
CREATE TABLE #sp_who (
spid smallint NOT NULL ,
ecid smallint NOT NULL ,
status nchar (30) NOT NULL ,
loginame nchar (128) NOT NULL ,
hostname nchar (128) NOT NULL ,
blk char(5),
dbname nvarchar(128),
cmd nchar (16) NOT NULL)
insert into #sp_who exec sp_who
select * from #sp_who
where blk > 0
drop table #sp_who
--David|||select * from master..sysprocesses where blk > 0?
see
http://www.nigelrivett.net/sp_nrSpidByStatus.html
Nigel Rivett
www.nigelrivett.net
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Subscribe to:
Posts (Atom)