• Antelope Release 5.10 Linux CentOS release 7.6.1810 (Core) 3.10.0 2020-05-12

 

NAME

dbtables - return list of tables which use a field

SYNOPSIS

#include "db.h"

Tbl *dbtables(Dbptr db, char *fieldname)

DESCRIPTION

This routine provides a means of finding which tables in a schema (database) use a particular field. Given the input database pointer and the name of a field, dbtables returns a Tbl list of all the tables which use that field.

EXAMPLE



% cat tdbtables.c
#include "db.h"
#include <stdio.h>

main ( argc, argv )
int argc ;
char **argv ;
{
    Dbptr db ;
    Tbl *tbl ;
    int i, n ;

    if ( argc != 3 )
        die ( 0, "Usage: %s database field\n", argv[0] ) ;

    db = dblookup ( db, argv[1], 0, 0, 0 ) ;
    tbl = dbtables ( db, argv[2] ) ;

    printf ( "The field %s in database %s is used in:\n",
        argv[2], argv[1] ) ;
    n = maxtbl ( tbl ) ;
    for ( i=0 ; i<n ; i++ )
        printf ( " %s", gettbl ( tbl, i ) ) ;
    printf ( "\n" ) ;
    return 0 ;
}
% tdbtables junk sta
The field sta in database junk is used in:
 affiliation arrival assoc sensor site sitechan stamag stassoc
 wfdisc wftape seedformat seedindex wfedit calibration stage
% 

RETURN VALUES

In the event of an error, the Tbl list returned is a null list.

LIBRARY

$(DBLIBS)

SEE ALSO

dbquery(3)

AUTHOR

Daniel Quinlan
Printer icon