Instead of using a SELECT statement build an index on TRADE_CODE in the TRADES file. Use the unibasic index command SETINDEX to tell you if a specified value has any entries in the TRADES file.
I don't think a trigger subroutine is an appropriate place for a SELECT statement. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of jonathanm Sent: Thursday, April 21, 2011 11:03 AM To: [email protected] Subject: [U2] Very Weird Trigger Behavior 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 <html> <body> ________________________________ Dave Davis Team Lead, R&D P: 614-875-4910 x108 F: 614-875-4088 E: [email protected] [http://www.harriscomputer.com/images/signatures/HarrisSchools.gif] [http://www.harriscomputer.com/images/signatures/DivisionofHarris.gif] 6110 Enterprise Parkway Grove City, OH 43123 www.harris-schoolsolutions.com This message is intended exclusively for the individual or entity to which it is addressed. This communication may contain information that is proprietary, privileged or confidential or otherwise legally exempt from disclosure. If you are not the named addressee, you are not authorized to read, print, retain, copy or disseminate this message or any part of it. If you have received this message in error, please notify the sender immediately by e-mail and delete all copies of the message. </body> </html> _______________________________________________ U2-Users mailing list [email protected] http://listserver.u2ug.org/mailman/listinfo/u2-users
