version 2004 (Modified)
With 4D Server, you now have three situations in which you can execute 4D code on the server machine:
Triggers
Stored procedures
Database methods
Triggers
A Trigger is a method attached to a table. Triggers can prevent "illegal" operations on your database records. They are a very powerful tool to restrict operations on a table, as well as to preventaccidental data loss or tampering. For example, in an invoicing system, you can prevent anyone from adding an invoice without specifying the customer to whom the invoice is billed.
Triggers are executed on the machine where the database engine is actually located. On 4D Server, triggers are executed within the context of the acting process on the server machine, not on the client machine. With 4D Server, a trigger executes within the context of the user processes that invokes the database operation. The trigger, however, has no access to the process variables of the user process.
For more information about triggers, see the section Triggers of the 4th Dimension Language Reference manual.
Stored Procedures
A stored procedure is project method executing a process method in a process running on the server machine (or, starting from 4D Server version 6.5, on any client machine), instead of on the client machine which has launched the method. See the section Stored Procedures.
Database Methods
Four database methods are executed only on the server machine:
On Server Startup Database Method
On Server Shutdown Database Method
On Server Open Connection Database Method
On Server Close Connection Database Method
Four other database methods can be executed either on the server machine or a client machine depending on the context:
On Web Authentication Database Method
On Web Connection Database Method
On Backup Startup Database Method
On Backup Shutdown Database Method
See the corresponding sections in this manual and in the 4th Dimension Language Reference manual for more information on the database methods.
4D Server and Variables
4D Server maintains one table of interprocess variables. The scope of these variables is the server machine. When running a compiled database, the interprocess variable table definition is common between the server and all the clients machines, each machine having its own instance.
Each stored procedure has its own table of process variables. When running a compiled database, the process variable table definition is common between between all stored procedures and user process running on all clients machines, each process having its own instance.
In interpreted mode, the database methods and triggers can create and use process variables dynamically during each phase of execution. This is not true in compiled mode. When running a compiled database, database methods and triggers share only one common table of process variables (whose definition is identical to that of the other processes).
4D Server and Sets
With 4D Server, interprocess and process sets are maintained on the server machine, while local sets are maintained on the client machines. For more information, see the section 4D Server and Sets.