Content-type: text/html; charset=UTF-8 Man page of qread

qread

Section: Herrin Software Development, Inc. (1)
Updated: 21 Oct 2000
Index Return to Main Contents
 

NAME

qread - Read an entry from a QDDB database and print it as a TCL list.  

SYNOPSIS

qread Relation Start Length Number Type
 

DESCRIPTION

qread reads a record from the QDDB database Relation and outputs a TCL list consisting of the contents of the record. qread is intended as a tool for TCL/TK scripts only. The KeyList argument (Start Length Number Type) is generally obtained from a query(1) Relation -tcl command.  

OUTPUT FORMAT

qread prints the record in the following format (following the Schema described in the query(1) manual page):

    {
        $NUMBER$ 10654
        Author,1 {The first author}
        Author,2 {The second author}
        Title,1 {The Title to "Some Juicy Book"}
        ISBN,1 {ISBN X-XXX-XXXXX-X}
        Description,1 {This is a really great book!!!
Everyone should read this book.}
    }

The first two elements of this list describe the unique identifier of the record. The line $NUMBER$ 10654 indicates that this is record number 10654. This information might be used by qdel(1) to delete the record. The remainder of the list contains elements describing the attribute name/instance and value of each non-empty attribute in the record. Even-numbered elements X, excluding the first two elements, contain the name of the attribute and its instance number separated by a comma. Odd-numbered elements X+1 contain the value of the attribute described by element X.  

USAGE

query/qread are generally used by a TCL/TK script containing code similar to (but much more efficient than:-) the following:

    # Example TCL/TK usage of query/qread.
    set query_result [exec query Relation -tcl -norows -any 'my words' -print Attr1:10 Attr2:10]
    foreach i $query_result {
        # Display each 20-character row referenced by [lindex $i 0].
    }
    # Read all the records, calling do_something for each field in each record.
    foreach i $query_result {
        set keylist [lindex $i 1]
        set record [eval "exec qread $keylist"]
        set record_number [lindex $record 1]
        set fields [lreplace $record 0 1]
        set len [llength $fields]
        for {set j 0} {$j < $len} {incr j 2} {
            set tmp [split [lindex $fields $j] ","]
            set attribute_name [lindex $tmp 0]
            set attribute_instance [lindex $tmp 1]
            set attribute_value [lindex $fields [expr $j + 1]]
            # display the attribute or whatever
            do_something $attribute_name $attribute_instance $attribute_value
        }
    }

 

SEE ALSO

qedit(1), qdel(1), query(1)  

DIAGNOSTICS

qread exits with an exit status of 1 if any error occurs and an exit status of 0 otherwise. This is sufficient to cause TK scripts using qread to display an informative error box if an error occurs.  

BUGS

None known.  

REFERENCES

A Guide to QDDB
Eric H. Herrin II and Raphael A. Finkel

Qddb User's Guide

An ASCII Database for Fast Queries of Relatively Stable Data
Eric H. Herrin II and Raphael A. Finkel
Computing Systems, Volume 4 Number 2
University of California Press, Berkeley CA

Schema and Tuple Trees: An Intuitive Structure for 
Representing Relational Data
Eric H. Herrin, II and Raphael A. Finkel
Computing Systems, Volume 9, Number 2
MIT Press, Cambridge MA


 

Index

NAME
SYNOPSIS
DESCRIPTION
OUTPUT FORMAT
USAGE
SEE ALSO
DIAGNOSTICS
BUGS
REFERENCES

This document was created by man2html, using the manual pages.
Time: 18:55:30 GMT, October 31, 2018