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.
|
|
|
 |
|