Programmer s Guide to the TBL Facility

Similar documents
Programmer s Guide to the SNP Facility

Programmer s Guide to the UID Facility

Programmer s Guide to the FIS Facility

Programmer s Guide to the SRV Facility

Programmer s Guide to the IE Facility

Programmer s Guide to the DCM Facility

CS240: Programming in C

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

Pointers, Dynamic Data, and Reference Types

Short Notes of CS201

CS201 - Introduction to Programming Glossary By

Data Storage. August 9, Indiana University. Geoffrey Brown, Bryce Himebaugh 2015 August 9, / 19

CS240: Programming in C

A flow chart is a graphical or symbolic representation of a process.

Robust Programming. Style of programming that prevents abnormal termination and unexpected actions

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

HIMSS and RSNA Integrating the Healthcare Enterprise IHE/MESA Export Receiver Tests

C-types: basic & constructed. C basic types: int, char, float, C constructed types: pointer, array, struct

Introduction. This project will focus primarily on processes.

Data Structures and Algorithms for Engineers

Lecture 10: building large projects, beginning C++, C++ and structs

Writing Functions in C

Introduction to Linked Lists

What the CPU Sees Basic Flow Control Conditional Flow Control Structured Flow Control Functions and Scope. C Flow Control.

Unlike the methods of all other objects in the MPI, Control object methods are not thread-safe. Error Messages

CS 370 The Pseudocode Programming Process D R. M I C H A E L J. R E A L E F A L L

TPMC901-SW-95. QNX4 - Neutrino Device Driver. User Manual. The Embedded I/O Company. 6/4/2 Channel Extended CAN-Bus PMC

GSM Library. Version 3.1. User Manual.

Airence C Library v1.2 for Windows

(2-1) Data Structures & The Basics of a Linked List I. Instructor - Andrew S. O Fallon CptS 122 (August 27, 2018) Washington State University

Review of the C Programming Language for Principles of Operating Systems

Singly linked lists in C.

V850 Calling Convention

CS11001/CS11002 Programming and Data Structures (PDS) (Theory: 3-1-0) Allocating Space

A Fast Review of C Essentials Part I

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

HIMSS and RSNA Integrating the Healthcare Enterprise IHE/MESA Time Client Tests

Type Checking. Prof. James L. Frankel Harvard University

Discussion 3 Richard Guo Advanced C 01/28/09

EL6483: Brief Overview of C Programming Language

12 CREATING NEW TYPES

int result; int waitstat; int stat = PmcaAsyncGetGain(&result); // stat receives request id

CAN Module Documentation

CSE351 Spring 2010 Final Exam (9 June 2010)

Final assignment: Hash map

CS349/SE382 A1 C Programming Tutorial

Data Representation and Storage

Section Notes - Week 1 (9/17)

MPLAB C1X Quick Reference Card

a data type is Types

Features of C. Portable Procedural / Modular Structured Language Statically typed Middle level language

CS113: Lecture 9. Topics: Dynamic Allocation. Dynamic Data Structures

Variables. Data Types.

Mellanox Scalable Hierarchical Aggregation and Reduction Protocol (SHARP) API Guide. Version 1.0

RFC: HDF5 File Space Management: Paged Aggregation

C Language, Token, Keywords, Constant, variable

CS113: Lecture 9. Topics: Dynamic Allocation. Dynamic Data Structures

Dept. of Computer and Information Science (IDA) Linköpings universitet Sweden

.NET Wrapper SDK Descriptor

CSE351 Spring 2010 Final Exam (9 June 2010)

ECE 30 Introduction to Computer Engineering

CSE 374 Programming Concepts & Tools. Hal Perkins Spring 2010

CSC 1600 Memory Layout for Unix Processes"

Data Representation and Storage. Some definitions (in C)

Motivation was to facilitate development of systems software, especially OS development.

C Structures, Unions, Bit Manipulations, and Enumerations

This manual is for Libffi, a portable foreign-function interface library. Copyright c 2008, 2010, 2011 Red Hat, Inc. Permission is granted to copy,

int fnvgetconfig(handle h, UINT32 id, const void *cfg, size_t sz);... 4

CSCI 2212: Intermediate Programming / C Review, Chapters 10 and 11

Dynamic Invocation Interface 5

Introduction to C. Robert Escriva. Cornell CS 4411, August 30, Geared toward programmers

The X Font Library. Keith Packard MIT X Consortium. David Lemke Network Computing Devices

C Programming Review CSC 4320/6320

BLM2031 Structured Programming. Zeyneb KURT

HIMSS and RSNA Integrating the Healthcare Enterprise IHE/MESA Patient ID Source Tests

OBJECT ORIENTED PROGRAMMING USING C++

Introduction to C++ Systems Programming

C Review. MaxMSP Developers Workshop Summer 2009 CNMAT

Introduction to C. Ayush Dubey. Cornell CS 4411, August 31, Geared toward programmers

CS201 Some Important Definitions

Review of the C Programming Language

Procedures, Parameters, Values and Variables. Steven R. Bagley

Character Strings. String-copy Example

Chapter 10. Programming in C

Remote Procedure Call Implementations

Kakadu and Java. David Taubman, UNSW June 3, 2003

Data Transfer with UTM

(6-1) Basics of a Queue. Instructor - Andrew S. O Fallon CptS 122 (September 26, 2018) Washington State University

bytes per disk block (a block is usually called sector in the disk drive literature), sectors in each track, read/write heads, and cylinders (tracks).

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA.

Midterm Exam Answers Instructor: Randy Shepherd CSCI-UA.0201 Spring 2017

Structures, Unions, and Typedefs

More Shared Memory Programming

nftables switchdev support

AET60 BioCARDKey. Application Programming Interface. Subject to change without prior notice

EECS 388 C Introduction. Gary J. Minden August 29, 2016

CSCI 350: Getting Started with C Written by: Stephen Tsung-Han Sher June 12, 2016

Memory and Addresses. Pointers in C. Memory is just a sequence of byte-sized storage devices.

Self-referential Structures and Linked List. Programming and Data Structure 1

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

Transcription:

Programmer s Guide to the TBL Facility A Facility for Manipulating Tables in a Relational Database David E. Beecher Mallinckrodt Institute of Radiology Electronic Radiology Laboratory 510 South Kingshighway Boulevard St. Louis, Missouri 63110 314/362-6965 (Voice) 314/362-6971 (FAX) Version 2.10.0 August 3, 1998 Copyright (c) 1995, 1998 RSNA, Washington University /wuerlb/documentation/dicom/facilities/tbl.frm

1 Introduction The TBL routines provide a structured access mechanism for tables defined using pre-existing database products. These routines currently support a locally engineered database system, and the commercially available Sybase line of database products. This library includes routines to open and close individual tables (TBL_Open and TBL_Close), as well as insertion (TBL_Insert), deletion (TBL_Delete), selection (TBL_Select), and modification (TBL_Update). Additionally, a layout routine (TBL_Layout) is provided to allow the user to determine the number and type of columns present in a particular table. This library was designed primarily for the support of other facilities (e.g. IDB facility), but is also used directly by various other applications.data Structures 2 Data Structures tbl.h is the primary include file for applications wishing to use the facility. There are 3 primary data structures defined which are of use to the developer. They are the field, criteria, and update structures (TBL_FIELD, TBL_CRITERIA, and TBL_UPDATE). These structures are used to specify field lists, criteria lists, and value lists for insertions, deletions, updates, etc. These structures are defined as follows: typedef struct { char *Field; TBL_OPERATOR Operator; TBL_VALUE Value; } TBL_CRITERIA; typedef struct { char *Field; TBL_VALUE Value; } TBL_FIELD; typedef struct { char *Field; TBL_FUNCTION Function; TBL_VALUE Value; } TBL_UPDATE; TBL_FUNCTION and TBL_OPERATOR are typedefed as follows: typedef enum { TBL_NULL,TBL_NOT_NULL,TBL_EQUAL, TBL_NOT_EQUAL,TBL_GREATER, TBL_GREATER_EQUAL,TBL_LESS, TBL_LESS_EQUAL,TBL_LIKE,TBL_NOP } TBL_OPERATOR 1/12

typedef enum { TBL_SET,TBL_INCREMENT,TBL_DECREMENT, TBL_ZERO,TBL_ADD,TBL_SUBTRACT } TBL_FUNCTION In general, arrays of fields, criteria, and updates are passed to the routines to either provide information or as a place holder for information to be returned from that function. These arrays are always terminated by supplying a null string in the Field element of the structure. Since a general mechanism to deal with any data type was desired, the TBL_VALUE structure was defined as follows: typedef struct { TBL_DATATYPE Type; int AllocatedSize; int Size; int IsNull; union { void *Other; short *Signed2; int *Signed4; unsigned short *Unsigned2; unsigned int *Unsigned4; float *Float4; double *Float8; char *String; char *Text; void *BinaryData; } Value; } TBL_VALUE; Notice that it is the users responsibility to allocate the proper amount of storage for the data item to be stored, as well as assigning a pointer to that storage to the proper data element of this structure. Finally, TBL_DATATYPE is defined as an enum with the following code: typedef enum { TBL_OTHER,TBL_UNSIGNED2,TBL_UNSIGNED4, TBL_SIGNED2,TBL_SIGNED4,TBL_FLOAT4, TBL_FLOAT8,TBL_STRING,TBL_TEXT, TBL_BINARYDATA } TBL_DATATYPE; 3 Include Files Any applications needing to use this facility should include the following files: #include dicom.h #include tbl.h. 2/12

In addition, Sybase users need to set at least one environment variable in order to use this facility. Sybase uses the environment variable DSQUERY to determine which server to use. The server names available to Sybase are listed in the interfaces file located in the home directory of the sybase user. This facility first looks at the environment variable CTN_SYBASE_SERVER to determine the server to use, then at the variable DSQUERY. One of these two variables must be correctly set in order to use this facility. 4 The following returns are defined from the TBL routines: Operation completed successfully TBL_UNIMPLEMENTED The operation attempted is currently unimplemented TBL_ALREADYOPENED The table/database pair is already opened TB DBNOEXIST Specified database does not exist TBL_TBLNOEXIST Specified table does not exist TBL_NOMEMORY There is no more memory available via malloc TBL_CLOSERROR The identified in the close does not exist TBL_BADHANDLE The passed is invalid TBL_NOFIELDLIST The null pointer was passed for the field list TBL_SELECTFAILED The select operation failed from bad specifications TBL_EARLYEXIT The select callback routine returned something other than and caused an early termination of this select TBL_DELETEFAILED The delete operation failed from bad specifications TBL_INSERTFAILED The insert operation failed from bad specifications TBL_UPDATEFAILED The update operation failed from bad specifications TBL_DBINITFAILED The initial database open operation failed TBL_NOCOLUMNS The specified table contains no columns TBL_NOCALLBACK No callback function was specified in the TBL_Layout routine 5 TBL Routines This section provides detailed documentation for each TBL facility routine. 3/12

TBL_Close TBL_Close - close the specified table in the named database CONDITION TBL_Close(TBL_HANDLE **) The point to the database/table pair to be closed.. Locates the specified in the call and removes that entry from the internal list maintained by this facility. TBL_CLOSERROR 4/12

TBL_Debug TBL_Debug -This function controls the printing of Sybase error messages CONDITION TBL_Debug(BOOLEAN flag); flag The variable that controls whether or not error messages from sybase are printed. If flag is TRUE, error messages from Sybase will be printed, if FALSE, error messages from Sybase will be suppressed. 5/12

TBL_Delete TBL_Delete -This function deletes the specified records from the specified table. CONDITION TBL_Delete(TBL_HANDLE **, TBL_CRITERIA *criterialist) The pointer for the database/table pair to be accessed for deletion. This table must be open. criterialist Contains a list of the criteria to use when deleting records from the specified table. A null list implies that all records will be deleted. The records selected by the criterialist are removed from the database/table indicated by. BL_BADHANDLE TBL_DELETEFAILED 6/12

TBL_Insert TBL_Insert -This function inserts records into the named table. CONDITION TBL_Insert(TBL_HANDLE **, TBL_FIELD *fieldlist) fieldlist The pointer for the database/table pair to be accessed for insertion. This table must be open. Contains a list of the keyword/value pairs to be inserted into the specified table. The table values contained in fieldlist are added to the database and table specified by. Each call inserts exactly 1 (one) record. It is the users responsibility to ensure that the correct number of values are supplied for the particular table, and that any values which need to be unique (i.e. for the unique key field in a table), are in fact unique. TBL_BADHANDLE TBL_NOFIELDLIST TBL_INSERTFAILED 7/12

TBL_Layout TBL_Layout -This function returns the columns and their types of a particular table specified by. CONDITION TBL_Layout (char *database, char *table, CONDITION (*callback)(), void *ctx) database The name of the database to use table The name of the table to use. callback The callback function invoked whenever a new record is retrieved from the database. It is invoked with parameters as described below. ctx Ancillary data passed through to the callback function and untouched by this routine. As each column is retrieved from the specified table, the callback function is invoked as follows: callback( TBL_FIELD *fieldlist, void *ctx); fieldlist contains the field name and the type of the column from the table specified. ctx contains any additional information the user originally passed to the layout function. If callback returns any value other than, it is assumed that this function should terminate and return an abnormal termination message (TBL_EARLYEXIT), to the routine which originally invoked TBL_LAYOUT. TBL_BADHANDLE TBL_NOCALLBACK TBL_SELECTFAILED TBL_TBLNOEXIST TBL_NOCOLUMNS TBL_EARLYEXIT 8/12

TBL_NextUnique TBL_NextUnique -this function is a simple unique number generator CONDITION TBL_NextUnique(TBL_HANDLE **, char *name, int *unique) name unique The of the previously opened database/table name pair. The name of the unique number to retrieve The unique number is stored here. TBL_NextUnique retrieves the next unique number for the given name. The name must be a valid unique number name as specifed in the appropriate table definition. After the current number is retrieved and placed in unique, this value is incremented and replaces the old value in the database. This function will generate approixmately 2,147,483,647 unique numbers before repeating. TBL_BADHANDLE TBL_SELECTFAILED TBL_UPDATEFAILED 9/12

TBL_Open TBL_Open -this function opens the specified table in the specified database. It creates a new for this particular table and passes that identifier back to the user. CONDITION TBL_Open(char *databasename, char *tablename, TBL_HANDLE **) databasename The name of the database to open tablename The name of the table to open which is contained in the aforementioned database The pointer for the new identifier created for this database/table pair is returned through The first time TBL_Open is invoked, database specific routines may be called to allocate the communication structures needed for subsequent operations. If the database/table pair has already been opened, the caller is returned a reference to the already opened table. A unique (address) is then created for this pair and returned to the user for subsequent table operations. TBL_Open used to return an error when the caller tried to open a table that was already open. The function has been modified to allow the user to open the table multiple times. The user needs to call DB_Close one time for each time that a table is opened. TBL_DBINITFAILED TBL_TBLNOEXIST TBL_NOMEMORY 10/12

TBL_Select TBL_Select -This function selects some number of records (possibly zero) that match the criteria specifications given in the input parameter criterialist CONDITION TBL_Select( TBL_HANDLE **, TBL_CRITERIA *criterialist, TBL_FIELD *fieldlist, int *count, CONDITION (*callback)(), void *ctx) criterialist fieldlist count ctx The pointer to the database/table pair to be accessed. This table must be open. Contains a list of the criteria to use when selecting records from the specified table Contains a list of the fields to be retrieved from each record that matches the criteria specification. It is an error to specify a null fieldlist. Contains a number that represents the total number of records retrieved by this particular select. If this parameter is null, then an internal counter is used and the final count will not be returned when the select finishes. Ancillary data passed through directly to the callback function and untouched by this routine. As each record is retrieved from the database, the fields requested by the user (contained in fieldlist), are filled with the information retrieved from the database and a pointer to the list is passed to the callback routine designated by the input parameter callback. The callback routine is invoked as follows: callback( TBL_FIELD *fieldlist, long count, void *ctx); Count contains the number of records retrieved to the point. ctx contains any additional information the user originally passed to this select function. If callback returns any value other than, it is assumed that this function should terminate (i.e. cancel the current db operation), and return an abnormal termination message (TBL_EARLYEXIT) to the routines which originally invoked the select. TBL_BADHANDLE TBL_DBINITFAILED TBL_NOFIELDLIST TBL_SELECTFAILED TBL_EARLYEXIT 11/12

TBL_Update TBL_Update -This function updates existing records in the named table. CONDITION TBL_Update(TBL_HANDLE **, TBL_CRITERIA *criterialist, TBL_FIELD *fieldlist); criterialist fieldlist The pointer to the database/table pair to be accessed for the modification. This table must be open. Contains a list of the criteria to use when selecting records from the specified table Contains a list of the keyword/value pairs to be updated in the specified table. The records which match the (ANDED) criteria in criterialist are retrieved and updated with the information contained in fieldlist. Only the fields contained in fieldlist will be updated with this call. TBL_BADHANDLE TBL_NOFIELDLIST TBL_INSERTFAILED 12/12