Sample Databases |
Top Previous Next |
ComCap includes various SQL script files, newdb-xx.sql and storedproc-xx.sql where xxx is a database type, containing SQL statements to create a COMCAP SQL database with four example tables, and stored procedures (for some databases only) to add records to those tables and provide limited reporting.
The help pages for the specific databases explain how to use the SQL script files.
Sample Tables
There are four sample tables in the COMCAP database:
While ComCap can be used to write directly to these, or any other, SQL tables, it is generally recommended that stored procedures are used instead since these allow data validation and manipulation to be performed using SQL functions and commands. For instance, dates and times may be manipulated using SQL string functions into unambiguous formats that SQL will accept, ideally ISO format (yyyy-mm-ddThh:mm:ss.zzz). All stored procedures called by ComCap must return a single row resultset with two columns, retcode and retmess, with retcode set to 100 for success, anything else results in ComCap reporting an error with the retmess (this is illustrated in storedproc-mssql.sql).
ComCap handles two columns specially, serial_nr and event_time, if used. Note these column names must not be used for other purposes if ComCap is told to use them. These extra columns are updated with the channel Serial Number and the time that the event was added to the database, if specified, and are usually the unique key for the table. The Serial Number is the same as used for adding escaped text to the captured data and the starting number and length may be specified on the Logging tab. While these two special columns will provide a unique database key where there is nothing guaranteed unique in the captured data, it is generally recommended that the Serial Number and event time are added as escaped text to the captured line, and then selected in the data format as columns for the database, this has the advantage of keeping the logged files the same as the database.
Sample Stored Procedures There are six sample stored procedure supplied to put data into the various sample tables:
The storedproc-mssql.sql file also has several xx_lst sample stored procedures to list rows in each of the four sample tables by date range, and some SQL statements that can be used to find out how many rows have been saved to each table, and to truncate the tables to remove all rows.
To set-up ComCap to save captured data to a database, the SQL table and ideally stored procedure must be created first, to allow ComCap to read the column and parameter definitions. It is also recommended that some data is first captured, which will considerably ease setting the Data Format that defines how columns will be taken from captured data.
|