If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Counting Rows

Started by pyne, 28 Sep 2005 07:37:58 AM

Previous topic - Next topic

pyne

Hi,
Ã,  Ã,  Ã,  Ã,  I'm totally lost trying to find a way of counting the number of rows or records that reside in a table.  I need to do this, and assigning the value returned to a define or temporary variable.
I hope this makes sense, and that someone can help me.

CoginAustin

This is gossip?

Please post in the appropriate place so we know what your asking and how to answer. Thanks


pyne

I'm sorry, but it's not entirely obvious to me where else I could have posted my question.  Could you tell me the right place?

CoginAustin

Well, I am not sure either..lol

What program are you trying to get a count out of?


pyne

I'm designing a screen in quick / qdesign, and I'm accessing an SQL database.Ã,  What I need is a unique number for the primary key, and I thought, 'what better than the number of records in the table'.Ã,  I know there is a way of having the primary key increment itself as new records are entered, but the table was not originally set up that way, and I don't have the permissions to modify it.Ã,  Is there a way to count the rows? ???

Vaughn

I would be hesitant to use the number of rows for a unique number,
especially with a SQL database.  (Multi-user, anyway.)  If you
can't create a view "SELECT COUNT(*) FROM THE_TABLE", which
would be a read-only access, then
you would be forced to set up an internal procedure:

proc internal count_em_up
begin
let t_count = 0
while retrieving THE_TABLE sequential ;need to lock up THE_TABLE to be sure
  let t_count = t_count + 1
end

If you have lots of rows, you need to lock this for a long time.
I recently had a similar requirement.  I needed a unique sequence
number for printing.  I set up a new table with the number field in
it.  Now I lock this small table, get the value, use it, increment it
and update the table.  Nice short locking.
If you really need a unique key and your data access fields don't
give it to you, why don't you go to the system clock for a unique number?
Some sort of getsystemval should work for you.  What system are
you using?  I have only seen QUICK with OpenVMS so I can't really
give a detailed answer except with that platform.