/* * $Source$ * $Header$ */ #ifndef lint static char *rcsid_tdbcl_c = "$Header$"; #endif lint /************************************************************************/ /* /* tdbcl (test database client) /* ---------------------------- /* /* Author: Noah Mendelsohn (IBM T.J. Watson Research and MIT Project /* Athena) /* /* Copyright: 1986 MIT Project Athena /* /************************************************************************/ /* /* PURPOSE /* ------- /* /* A GDB client program which accesses a relational database /* using the services of GDB. /* /************************************************************************/ #include #include "gdb.h" int ftypes[] = {STRING_T, INTEGER_T, INTEGER_T}; char *fnames[] = {"name", "rank", "serial"}; int main(argc, argv) int argc; char *argv[]; { /*----------------------------------------------------------*/ /* /* DECLARATIONS /* /*----------------------------------------------------------*/ DATABASE db; /* this is the database */ /* we access */ int rc; /* return code from */ /* access_db */ TUPLE_DESCRIPTOR tpd; RELATION rel; #define MAX_OPS 50 OPERATION ops[MAX_OPS]; int next_op=0; /* next op to use */ int i; /*----------------------------------------------------------*/ /* /* EXECUTION BEGINS HERE /* /* Make sure the command line specifies the name /* of the host on which the server program is running. /* /*----------------------------------------------------------*/ if (argc != 3) { /* * Tell 'em the syntax */ fprintf(stderr, "tcl \n"); exit (4); } /*----------------------------------------------------------*/ /* /* Initialize the GDB library. /* /*----------------------------------------------------------*/ gdb_init(); /*----------------------------------------------------------*/ /* /* Create all the operations /* /*----------------------------------------------------------*/ for (i=0; i*name*<=tdbcl.name, >*serial*<=tdbcl.serial) where tdbcl.serial>200"); printf("return code from query is %d\n",rc); if (rc == 0) print_relation("Query result", rel); delete_relation(rel); rel = create_relation(tpd); rc = db_query(db, rel, /*argv[2]*/ "(>*name*<=tdbcl.name, >*serial*<=tdbcl.serial) where tdbcl.serial>200"); printf("return code from query is %d\n",rc); if (rc == 0) print_relation("Query result", rel); delete_relation(rel); delete_tuple_descriptor(tpd); return; }