 |
» |
|
|
 |
The example programs in this section are based on the
manufacturing database and the purchasing database that are a part of the
sample database environment, PartsDBE. (Reference the , appendix C.)
Informative comments and explanations are present throughout each listing.
The following programs are included:
COBEX30, using date/time functions to allow
input and display of DATE and DATETIME columns in European format.
COBEX9a, converting a column data type from CHAR to DATE.
Example Program Using Date/Time Functions |  |
The following program is intended as a framework
in which to illustrate
why you might use date/time functions and how they are implemented.
It is based on the manufacturing database, ManufDB, which is supplied
as part of the ALLBASE/SQL software package. The schema files used to
create the database are found in appendix C of the .
As you work with the program, you will also become familiar with
integrity contraints, since the BatchStamp column in the
TestData table references the BatchStamp column in the SupplyBatches
table.
You could enhance this program to fit your needs. One useful enhancement
might be to use bulk table processing rather than simple data manipulation
commands. Thus you could operate on duplicate BatchStamps within the TestData table.
Example Program Converting a Column from CHAR to DATE Data Type |  |
The next data conversion program is intended as a guide
should you decide
to convert any character (CHAR) columns in an existing table to a date/time
data type.
Before running this program, you must create a new table,
PurchDB.NewOrders, in PartsDBE. This table is similar to the PurchDB.Orders
table already existing in PartsDBE, except that the OrderDate column
is of the DATE data type.
(Reference the , appendix C.)
You can create the table by issuing the
following command from ISQL:
CREATE PUBLIC TABLE PurchDB.NewOrders(
OrderNumber INTEGER NOT NULL,
VendorNumber INTEGER,
OrderDate DATE)
IN OrderFS;
|
Example Program to Convert from CHAR to Default Data Type
|