Hello there,

I need help with the following:

I need to write a stored procedure to:

There are two tables CAT and CAT_REL
(only listing impt fields)

CAT has (id, child_count)
CAT_REL has (parent_cat_id)

I want to count (*) from CAT_REL, where CAT.id = CAT_REL.parent_cat_id) and compare it to the CAT.child_count field and ensure that they are the same, if not update CAT.id to be set to this.

eg,
CAT
id child_count
1 4
2 3

CAT_REL
parent_cat_id some_other_field
1 assas
1 rwer
1 fsdfsd
1 ds
2 sdfds
2 fdf
2 ewa

id is unique in CAT table and the child_count is meant to store the number of records in the CAT_REL table per id.

I have pathetic knowledge in PL/SQL so any help would be appreciated.

thanks in advance,
Nirasha