>>>Given:
>>> parent table w/ id & status fields.
>>> child table w/ parents id & its own status field.
>>> status is some value between 1 and 9.
>>>
>>>If I change the status of one of the children I want to update the parent
>>with the least value of all of its children.
>>>
>>>So with both childrens' status = 3 parents status will be 3, but if child
>>#1 status changes to 1 i want parents' status to = 1.
>>>
>>>update procedure on the child table:
>>>
>>>PROCEDURE _child_Update
>>>LOCAL lcItem, lcStatus, lcOldError, llError
>>>lcItem=child.itemid
>>>lcStatus=child.status
>>>lcOldError=ON("ERROR")
>>>ON ERROR llError=.T.
>>>llError=.F.
>>>SELECT child && is this legal in trigger?
>>>SCAN FOR child.itemid = lcItem
>>> IF status < lcStatus
>>> lcStatus = status
>>> ENDIF
>>>ENDSCAN
>>>BEGIN TRANSACTION
>
>why not
>lcAlias = alias()
>select * from child into cursor temp order by status
>go top
>lcStatus = temp.status
>use in temp
>select &lcAlias
>begin transaction
this does it
thanks dave
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only