|
Data definition statements let you specify the characteristics of your database. When you execute data definition statements, Pervasive.SQL stores the description of your database in a data dictionary. You must define your database in the dictionary before you can store or retrieve information.
Pervasive.SQL allows you to construct data definition statements to do the following:
The following sections briefly describe the SQL statements associated with each of these tasks. For general information about defining the characteristics of your database, refer to the Pervasive.SQL Programmer's Guide, available in the Pervasive.SQL Software Developer Kit (SDK).
You can create, modify, and delete tables from a database by constructing SQL using the following statements:
You can create and delete indexes from a database by constructing SQL s using the following statements:
You can create and delete triggers from a database by constructing SQL using the following statements:
Pervasive.SQL provides additional SQL control statements, which you can only use in the body of a trigger. You can use the following statements in triggers:
|
BEFORE
|
Defines the trigger execution before the INSERT, UPDATE, or DELETE operation.
|
|
AFTER
|
Defines the trigger execution after the INSERT, UPDATE, or DELETE operation.
|
A stored procedure consists of statements you can precompile and save in the dictionary. To create and delete stored procedures, construct statements using the following:
Pervasive.SQL provides additional SQL control statements, which you can only use in the body of a stored procedure. You can use the following statements in stored procedures:
|
IF...THEN...ELSE
|
Provides conditional execution based on the truth value of a condition.
|
|
Continues execution by leaving a block or loop statement.
|
|
|
Repeats the execution of a block of statements.
|
|
|
Repeats the execution of a block of statements while a specified condition is true.
|
In addition to the built-in functions, Pervasive.SQL allows you to create your own user-defined functions (UDF) and use them in Pervasive.SQL statements.
A user-defined function is a database object that encapsulates one or more Pervasive.SQL statements that can be reused. A user-defined function takes zero or more input arguments and evaluates a return value, which is a scalar value.
User-defined functions are always defined within the context of a database. Successful execution of this statement results in the storing of the UDF definition in the specific database. Once stored, the UDF can be modified, invoked, and deleted.
Pervasive.SQL supports scalar user-defined functions.
A scalar user-defined function returns a single value of the data type specified in the RETURNS clause of the Pervasive.SQL statement. A scalar UDF can contain multiple Pervasive.SQL statements. You can specify any data type value for the returned data except text, ntext, image, cursor, or timestamp.
To create and delete user-defined functions, construct statements using the following:
|
Creates a scalar user-defined function in the database.
|
|
|
Deletes a scalar user-defined function from the database.
|
|
Chapter contents
Prev topic: SQL Overview
|