I use the command below to create triggers on a table for insert update and delete
CREATE TRIGGER ON SomeTableName FOR INSERT AS InsertEvent()
then i have to go, modify the database and choose "Edit Stored Procedures" from the Database menu, of the Visual FoxPro IDE, to finally bring the stored procedure window and define a function called
FUNCTION InsertEvent(tableName, primaryKeyField, dDateTime) && parameters may be anything, to make the example simple i chose those...
&& again the messagebox is just to test the function call when a record is inserted...works
MESSAGEBOX(tableName +" " + primaryKeyField)
RETURN .T.
ENDFUNC
my question:
i would like to be able to define the function InsertEvent(...) programatically, without having to open the database, modify it, and modify the stored procedures, same as i do to create a trigger programatically using the CREATE TRIGGER
command.
the reason i need to do it automatically is because i have an existing database and i wrote a script to apply some changes to each table of that database.
trigger can coexsit with stored procedures in a single file...here's a solution for those interested to know: