What is the workarea alias when a trigger is executed?
When a trigger fires, VFP code is executed. What is the workarea while executing that code?
CREATE DATABASE xx
CREATE TABLE temp (name c(10))
CREATE TABLE AnotherTemp (name c(10))
CREATE TRIGGER ON temp FOR INSERT as name !=ShowAlias(ALIAS())
CLOSE DATABASES all
USE temp ALIAS foo
USE temp again ALIAS bar IN 2
USE anothertemp IN 3 ALIAS fred
SELECT fred && select different area
INSERT INTO foo VALUES ("bb")
INSERT INTO bar VALUES ("BAR") && Trigger Fails
INSERT INTO foo VALUES ("FOO") && Trigger Fails
PROCEDURE ShowAlias(cAlias as String) as String
?PROGRAM(),cALIAS
RETURN cALIAS
From running this code, it’s clear that the Alias is always that of the cursor being updated, regardless of the Alias selected in the code that caused the trigger to fire.
Be careful! The “TEMP” table is actually used twice with 2 different aliases, neither of which is “TEMP”
Comments
Anonymous
October 31, 2005
DefaultValue assignments do the same thing, which one can use to one's advantage in DefaultValue UDFs. You don't have to worry about what work area is selected.Anonymous
June 16, 2009
PingBack from http://fixmycrediteasily.info/story.php?id=9314Anonymous
June 18, 2009
PingBack from http://firepitidea.info/story.php?id=585