Home » SQL & PL/SQL » SQL & PL/SQL » Row Count in Header
Row Count in Header [message #424113] Wed, 30 September 2009 04:52 Go to next message
GuestUser32
Messages: 26
Registered: August 2009
Junior Member
Hi

I am writing some rows from a table to a txt file.
I need to put a row count of the total rows in the txt file.
This row count needs to be in the header of the file.
However the format of my code is as follows:

Header put line

body loop put line

+1 row count

Therefore my row count is adding up during the loop and therefore I can't put it in my header as it hasnt been created yet.
Is there a way around this?

Thanks
Re: Row Count in Header [message #424118 is a reply to message #424113] Wed, 30 September 2009 05:09 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
You'll need to work out how many rows there will be be at the start.
Re: Row Count in Header [message #424121 is a reply to message #424113] Wed, 30 September 2009 05:15 Go to previous messageGo to next message
bonker
Messages: 402
Registered: July 2005
Senior Member
Can you do count(*) over () as part of your cursor select query and then print that value as header?

[Updated on: Wed, 30 September 2009 05:15]

Report message to a moderator

Re: Row Count in Header [message #424143 is a reply to message #424113] Wed, 30 September 2009 05:50 Go to previous messageGo to next message
Michel Cadot
Messages: 63801
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
What is your client program? SQL*Plus?

Regards
Michel
Re: Row Count in Header [message #424147 is a reply to message #424143] Wed, 30 September 2009 06:01 Go to previous messageGo to next message
GuestUser32
Messages: 26
Registered: August 2009
Junior Member
I used a count query to count the rows in the table. This solved my problem

Thanks for the help!
Re: Row Count in Header [message #424152 is a reply to message #424147] Wed, 30 September 2009 06:08 Go to previous message
Michel Cadot
Messages: 63801
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
So you execute the query twice?

Regards
Michel
Previous Topic: stored procedure required
Next Topic: ora 00600 internal error
Goto Forum:
  


Current Time: Sat Sep 24 16:22:04 CDT 2016

Total time taken to generate the page: 0.08003 seconds