Log In    |    Knowledge Base    |    4D Home
Tech Tip: Stored Procedures ease routine taks
Published On: July 1, 1998

When you want your 4D V6 client-server database to perform a task that will take time but doesn't require user interaction, consider using a Stored Procedure (started by an Execute on Server command) or a Trigger. Both of these spawn a process on the server machine that doesn't need to communicate across the network. Since accessing data on the same machine is much faster than accessing the same data across the network, your task should speed up considerably (5 to 10 times faster is typical). Use a Trigger if the operation involves maintaining the database automatically whenever records are added, modified or deleted. Good examples are time and date stamping records, or building fields composed of the data in other fields (perhaps for compound sorting or faster searching). Think of processes as if each one is a separate user. Processes have their own variables, current selection, current record, etc. associated with a user in a database. There are just a few things to watch out for: E A stored procedure may use a lot of the server's processor time, which can slow down other users. If this is likely to be a problem, insert some Delay Process commands to give time to other processes. E A trigger has certain limits on what it can do. Carefully read the section on Triggers in the Language Reference Manual before using them. E A stored procedure does not have access to certain client and variable information. Read the section on Stored Procedures in the Server reference manual (on your Product CD) before using them.