Hi, all. I'm new to this forum, but have been programming multivalue database
apps for years. I ran across something here that really has me puzzled. I
wonder if anyone has seen something like this and might be able to shed a
bit of light as to what's happening.
I'm running Unidata 6.0 on hpux.
I have a trigger set up to run before deletions take place on a file called
CODE_DEFS. The file just contains code numbers (ID) and their
meaning/description. There's another file, TRADES, that contains a field,
TRADE_CODE, that should have a many-to-one relationship with IDs in
CODE_DEFS. That is, the content of TRADE_CODE should match a record ID in
CODE_DEFS.
Before a record is deleted from CODE_DEFS, I want to ensure its ID does not
appear in any record in TRADES. That's where the trigger comes in. The
trigger is passed the ID of the record to be deleted. This is done via
parameter variable CODE_DEF_ID. The trigger program, CHECK_TRADES, has the
following logic:
-------------------------------------------------------------------------------
.
.
.
CMD='SELECT TRADES WITH TRADE_CODE = "':CODE_DEF_ID:'"'
EXECUTE CMD
IF SYSTEM(11) THEN
* there's a select list, so the code is still in use in TRADES.
* Return 0 in EXECUTE_STATUS to disallow the deletion.
EXECUTE_STATUS=0
END
.
.
.
-----------------------------------------------------------------------------------
The problem is when I try to delete a record from CODE_DEFS, using a TCL
DELETE command, I get the following error message.
'' is not a record in TRADES
Of course, there are two problems with the error message. Not only has it
lost the ID of the record to be deleted, it has also lost the name of the
file. Notice that it is looking in the TRADES file instead of CODE_DEFS.
I believe what's happening is when it EXECUTEs the CMD, the internal
variables for ID and filename are being reset. To support this hunch, I
changed the trigger routine so that CMD="DATE", causing it to execute the
TCL DATE command. Here's the error message from that:
'' is not a record in CODE_DEFS
And if I make CMD="COUNT CUST", which makes the trigger deal with a
completely unrelated file, I get this error message:
'' is not a record in @7X%
So, it appears that any EXECUTE is going to lose the ID, and if CMD deals
with any file, the filename is reset also.
I really need to have it perform the intended check before deletion. Any
ideas?
--
View this message in context:
http://old.nabble.com/Very-Weird-Trigger-Behavior-tp31450305p31450305.html
Sent from the U2 - Users mailing list archive at Nabble.com.
_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users