A Visual FoxPro program can create a database by using the CREATE DATABASE command, but the CREATE DATABASE command does not offer a way to create stored procedures. This article describes how a Visual FoxPro program can add stored procedures to a new or existing database.
To add a stored procedure to an existing table, use the APPEND PROCEDURE command to take a procedure from an existing text file and add it to a database's stored procedure.
- Create a new database, or open an existing one. For example, use the following command to create a database:
CREATE DATABASE mydata
- Create a text file that will contain the desired procedure(s) or open an existing procedure file. The text file should contain procedure code. Here is an example:The procedure file may contain as many procedures as you want to appear in the database's Stored Procedures.
IF state <> "WA" or state <>"NC"
WAIT WINDOW 'Invalid State'
- To append the procedure(s) to an existing database's Stored Procedures be sure the database is open, and issue the APPEND PROCEDURES command, as in this example:
OPEN DATABASE mydata EXCLUSIVE
APPEND PROCEDURE FROM textfile.txt && Replace textfile.txt with the
&& actual name of your text file.
APPEND PROCEDURE FROM textfile.txt OVERWRITE