HP c-tree-SQL ISQL and Tools manual Examples, For Record Statement

Models: c-tree-SQL ISQL and Tools

1 99
Download 99 pages 4.83 Kb
Page 84
Image 84

ISQL and Tools

record_length is the length of the fixed length record. This length should include the length of field or record delimiters, if any.

field_name is the name used to refer to a field in the data file.

delimiter_char is the field delimiter and is a single character. delimiter_char must be spec- ified as a literal.

delimiter_string is the record delimiter and can be a single character or a string. It must be specified as a literal.

start_position is the position where the field starts. It must be an unsigned integer.

end_position is the position where the field ends. It must be an unsigned integer.

The first position of each record is 1 and not 0.

If date, time, and timestamp types are to be dumped they can be specified as characters in the commands file. If it is a fixed length record then the type specification can be CHAR.

The following is an example of the DEFINE RECORD statement for fixed length records:

DEFINE RECORD rec_one OF FIXED LENGTH 20 AS (

fld1 POSITION (1:4) SHORT, fld2 POSITION (5:15) CHAR, fld3 POSITION (16:20) CHAR

) ;

5.5.2The FOR RECORD Statement

The FOR RECORD statement writes each valid record into the data file after selecting the record from the database. The syntax for the FOR RECORD statement is shown below:

FOR RECORD record_name DUMP INTO data_file_name

USING select_statement ;

The following are the variable descriptions of the FOR RECORD statement:

record_name specifies the same name used in the associated DEFINE RECORD statement.

data_file_name is the name of the output data file name.

select_statement is any valid SELECT statement.

5.6EXAMPLES

This section gives different types of examples for dbdump, both for variable length records as well as fixed length records. The data files can either be ASCII or binary files. If they are binary files they must be in the fixed length record format.

The following is the commands file to write records from the dept table. The output data file name is deptrecs_out which is an ASCII file in the variable length record format.

DEFINE RECORD dept_rec AS

5-4

FairCom Corporation

Page 84
Image 84
HP c-tree-SQL ISQL and Tools manual Examples, For Record Statement