CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 incremental updates in one-to-many relation

Print topic Send  topic

Author Message
Pinchas
Posted: 10/10/2002, 8:31 AM

CC2, Nonprogrammer, NonSQL.

Is there any solution (may be by SQL) for holding Counter fields in the "One" side (of a one-to-many relationship) which reflects always the amount of records relevant in the "many" side?
e.g. a counter in the ORDER table which reflects the value of number of details in the Order_Details Table ?

I mean,
When adding/deleting a detail record it increments/decrements the counter.

If there is no any automatic solution within SQL, how can it be done programaticcaly within CC events.
I'll be thankfull for a detail (code) answer.

What do you think about internal soluttin for that in CC?



Nicole
Posted: 10/11/2002, 7:00 AM

Hello,
I suppose that the easier way is to calculate records count using code in CC rather then store it in the db and update the table everytime the details table is updated.
As I understand you're using CC, so you can create master-detail forms using wizard. So you can calculate the records count using code like:
tmp = dlookup("detail_table", "count(*)", "foregi_key = " & ToSQL(GetParam("master_table_id"), "Number"))
You can use the code in the form or page Open events.
You'll find dlookup(), getparam(), tosql() function in common file.

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.