Thanks for the great tips guys, using stored procedures sounds like a
good way to go, having complete control. I date back way back to
R:base 4000 (and XRW, remember that?) but only got back to this
seriously a few years ago so my gap of knowledge with the Windows
generation has me stuck in some of the old ways I guess.
Is that pretty much the consensus, has most everyone abandoned rules?
On 2/21/2012 8:47 PM, Albert Berry wrote:
Dave, I never use rules, for what that is worth. We who have been
R;Basers for "several" years remember the days when rules were the way
to control data integrity, but the introduction of the relational
attributes have rendered them redundant. I would create a stored
procedure that you call to check the data using whatever rules you
would have set up and call it from the Done button, and you can then
control form closure and data saving exactly as you want it to be done.
The eep would then be reduced to CALL CheckProcedure (.fkid) where the
fkid is the unique link to the set you are examining.
Albert
On 21/02/2012 6:37 PM, Dave McCann wrote:
I have a strange issue with an EEP and some rule checking I am doing.
In one particular multi-table form in my project which gets some data
pre-populated into the underlying tables, then some remaining data
fields are edited to complete things. I wanted the rule checking to
occur at the end of the edit process (not when moving from table to
table) so I am turning RULES OFF and in my "Done" button EEP I set
RULES ON, do an UPDATE on the underlying data tables, trap the error
and remain on the form if there is an error. If there are no errors,
proceed to CLOSEWINDOW. If there are no rule errors everything works
fine.
The problems is if I execute the "Done" button EEP and there are rule
constraint errors, when they are corrected and the form is closed, it
proceeds to close the forms from which this form was opened. If I
repeat the error condition several times, when it finally closes
it'll close several levels of forms/menus even going so far as to
exit R:base or my compiled app all the way!
Maybe my logic is flawed - when I trace the code, seems to never hit
the code AFTER my UPDATE statements when the rule validation fails
and bring up the constraint errors. As an example, the PAUSE
statements never execute if a constraint error occurs, but they DO if
there are no constraint errors.
A snippet of what I'm doing...
SET RULES ON
SET ERROR VARIABLE ev
--refresh data in table to trigger constraint check on header table
UPDATE tinvheader SET invno=(invno) WHERE invno = .vinvno
SET VAR ev1=(.ev)
PAUSE 2 USING 'FIRST UPDATE OK'
--refresh data in table to trigger constraint check on detail table
UPDATE tinvdetail SET billitem=(billitem) WHERE invno = .vinvno
SET VAR ev2=(.ev)
PAUSE 2 USING 'SECOND UPDATE OK'
--no errors so finish up and close the form
IF ev1 = 0 AND ev2 = 0 THEN
...do some other things
CLOSEWINDOW
ENDIF
RETURN
Any ideas?
--
Dave McCann