当前位置: 首页>>代码示例>>C++>>正文


C++ dblookup函数代码示例

本文整理汇总了C++中dblookup函数的典型用法代码示例。如果您正苦于以下问题:C++ dblookup函数的具体用法?C++ dblookup怎么用?C++ dblookup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了dblookup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: get_instype

static int
get_instype (Dbptr db, char *instype, double *samprate)
{
    static Dbptr    dbsi = INVALID_DBPTR;
    static Hook    *hook = 0;
    long            nmatches;
    Tbl            *tbl;
    char            sta[MAX_STA_SIZE],
                    chan[MAX_CHAN_SIZE];
    double          time;
    char           *s;
    int             errors = 0;

    if (dbsi.database < 0) {
	Dbptr           dbsensor,
	                dbinstrument;
	dbsensor = dblookup (db, 0, "sensor", 0, 0);
	dbinstrument = dblookup (db, 0, "instrument", 0, 0);
	dbsi = dbjoin (dbsensor, dbinstrument, 0, 0, 0, 0, 0);
    }
    nmatches = dbmatches (db, dbsi, 0, 0, &hook, &tbl);
    switch (nmatches) {
      case dbINVALID:
      case 0:
	dbgetv (db, 0, "sta", sta, "chan", chan, "time", &time, NULL);
	complain (0, "no matches in sensor/instrument join for %s:%s @ %s",
		  sta, chan, s = strydtime (time));
	free (s);
	errors++;
	break;

      default:
	dbgetv (db, 0, "sta", sta, "chan", chan, "time", &time, NULL);
	complain (0, "too many matches (%ld) in sensor/instrument join for %s:%s @ %s",
		  nmatches, sta, chan, s = strydtime (time));
	free (s);
	errors++;
	/* FALLTHRU */

      case 1:
	dbsi.record = (long) gettbl (tbl, 0);
	dbgetv (dbsi, 0, "instype", instype, "samprate", samprate, NULL);
	break;
    }

    freetbl (tbl, 0);
    return errors;
}
开发者ID:NVSeismoLab,项目名称:antelope_contrib,代码行数:48,代码来源:dbresp2autodrm.c

示例2: join_tables

Dbptr join_tables(Dbptr db, Pf *pf, Arr *tables)
{
	char *table_name;
	int *ilogic;
	Tbl *t;
	Dbptr dbj;
	long int nrec;
	int i;
	int ntables=0;

	/* This is an exact copy of above, but it is duplicated because
	this function could get stolen by another future program
	because it is pretty general */
	t = pfget_tbl(pf,"join_tables");
	if(t == NULL)
	{
		elog_die(0,"No list of tables to be joined\n");
	}
	for(i=0;i<maxtbl(t);++i)
	{
		table_name = gettbl(t,i);
		ilogic = (int *)getarr(tables,table_name);
		if(ilogic == NULL)
		{
			elog_die(0,"Table %s was not handled previously by check_tables.\nProgramming logic error\n",
				table_name);
		}
		else if(*ilogic)
		{
			if(ntables == 0)
				dbj = dblookup(db,0,table_name,0,0);
			else
				dbj=dbjoin(dbj,dblookup(db,0,table_name,0,0),
					NULL,NULL,0,NULL,0);
			++ntables;
			dbquery(dbj,dbRECORD_COUNT,&nrec);
			if(nrec == 0)
			{
				elog_complain(0,
					"join_tables error\njoined database has 0 length after joining table %s\n",
					table_name);
				dbj.record = dbINVALID;
				return(dbj);
			}
		}
	}
	return(dbj);
}
开发者ID:NVSeismoLab,项目名称:antelope_contrib,代码行数:48,代码来源:db2segy.c

示例3: dbschema2sqlcreate

Tbl *
dbschema2sqlcreate( Dbptr db, long flags )
{
	Tbl	*sql;
	char	*cmd;
	Tbl	*tables;
	char	*table;
	long	itable;

	sql = newtbl( 0 );

	if( db.table >= 0 ) {
		
		cmd = generate_sqltable_create( db, flags );

		pushtbl( sql, cmd );

	} else {

		dbquery( db, dbSCHEMA_TABLES, &tables );

		for( itable = 0; itable < maxtbl( tables ); itable++ ) {

			table = gettbl( tables, itable );

			db = dblookup( db, "", table, "", "" );
			
			cmd = generate_sqltable_create( db, flags );

			pushtbl( sql, cmd );
		}
	}

	return sql;
}
开发者ID:ittaikurzon,项目名称:antelope_contrib,代码行数:35,代码来源:db2sql.c

示例4: opendb

int opendb( Dset *dset )
{
 
   char key[256];
   Tbl *sort_sta_ch_tm;
 
   if (dbopen_database ( dset->dbname, "r+", &(dset->db) ) == dbINVALID )
         die (0, "Can't open database %s\n",  dset->dbname );
 
    dset->db = dblookup ( dset->db, 0, "wfdisc", 0, 0);
    if ( dset->db.table == dbINVALID )
       die (0, "Can't open '%s' wfdisc table.\n", dset->dbname );
 
    /* Select specified sta&chan */
 
    sprintf( key,"(chan =~ /%s/ && sta=~ /%s/)\0", dset->chan, dset->sta );
    dset->db = dbsubset(  dset->db, key, 0 );
    sort_sta_ch_tm = strtbl("sta", "chan", "time", 0 ) ;
    dset->db = dbsort ( dset->db, sort_sta_ch_tm, 0, 0 ) ;
 
    dbquery ( dset->db, dbRECORD_COUNT, &(dset->dbrec) );
    if( dset->dbrec <= 0 )
       die( 0, " no record with sta == %s and chan == %s in %s.\n", 
                 dset->sta, dset->chan, dset->dbname );
 
 
    return 1;
 
}  
开发者ID:battistuz,项目名称:antelope_contrib,代码行数:29,代码来源:util.c

示例5: save_origerr

/*This function adds a single row to the origerr table for this event.

arguments:
	orid - orid assign to this solution
	h - Hypocenter object for this solution
	dbo - output db

This version doesn't set much of this large table.  Eventually, it 
needs to include all the error terms, but that function is not 
written yet. 

Author:  Gary L. Pavlis
Written:  February 1997
*/
void save_origerr(long orid, Hypocenter h, double **C, Dbptr dbo)
{
	double sdobs; 
	double lddate;
	/* Intentionally ignored: smajax,sminax,strike,sdepth,stime,
					conf,commid */

	dbo = dblookup(dbo,0,"origerr",0,0);

	/* Bad news here is that we can't save the more useful 
	statistics that this program calculates.  css3.0 only allows
	sdobs = sswr/ndgf */

	sdobs = h.rms_raw;
	lddate = std_now();
	if(dbaddv(dbo,0,
		"orid",orid,
                "sxx",C[0][0],
                "syy",C[1][1],
                "szz",C[2][2],
                "stt",C[3][3],
                "sxy",C[0][1],
                "sxz",C[0][2],
                "syz",C[1][2],
                "stx",C[0][3],
                "sty",C[1][3],
                "stz",C[2][3],
		"sdobs",sdobs,
                "lddate",lddate,
			NULL) == dbINVALID)
	{
		elog_die(1,"save_origerr: dbaddv error writing origerr record for orid %ld\n",
				orid);
	}
}
开发者ID:antelopeusersgroup,项目名称:antelope_contrib,代码行数:49,代码来源:relocate.c

示例6: save_emodel

/* This routines cautiously saves the emodel vector.  It is cautious
because the emodel table is not part of the css3.0 schema.  If it
cannot find info on the emodel table, it issues an error and returns.
Otherwise, it will save the emodel vector to this special table.
Author:  Gary L. Pavlis
Written: June 29, 1998 */
int save_emodel(int orid, float *emodel, Dbptr db)
{
	Dbptr dbemod;  

	dbemod = dblookup(db, 0,"emodel",0,0);
	if(dbemod.table == dbINVALID)
	{
		elog_log(0,"emodel table not defined for output database\nAdd genloc mods\n");
		return(1);
	}
	else
	{
		if(dbaddv(dbemod,0,
			"orid",orid,
			"emodelx",emodel[0],
			"emodely",emodel[1],
			"emodelz",emodel[2],
			"emodelt",emodel[3],
				NULL ) == dbINVALID)
		{
			elog_log(0,"dbaddv error for emodel table\n");
			return(-1);
		}
	}
	return(0);
}
开发者ID:EugeneGalipchak,项目名称:antelope_contrib,代码行数:32,代码来源:eqerror.c

示例7: save_run_parameters

void save_run_parameters(Dbptr db,Pf *pf)
{
	char *dir,*dfile;
	char filename[512];
	char *vm,*vm3d;
	int ierr;
	
	dir = pfget_string(pf,"pmelrun_archive_directory");
	if(dir==NULL)elog_die(0,"Parameter pmelrun_archive_directory not in parameter file\n");
	if(makedir(dir))
		elog_die(0,"makedir failed on directory %s\n",dir);
	dfile = pfget_string(pf,"pmel_run_name");

	
	vm = pfget_string(pf,"travel_time_model");
	vm3d=pfget_string(pf,"3Dreference_model");
	if( (vm==NULL) || (vm3d==NULL) )
		elog_die(0,"Missing required velocity model definitions\nCheck parameters travel_time model and 3Dreference_model\n");
	db = dblookup(db,0,"pmelruns",0,0);
	ierr=dbaddv(db,0,"pmelrun",dfile,
		"vmodel",vm,
		"vmodel3d",vm3d,
		"dir",dir,
		"dfile",dfile,0);
	if(ierr < 0) elog_die(0,
		   "dbaddv error on pmelrun table\nVerify schema extensions for dbpmel and that the pmel_run_name parameter is unique\n");

	strcpy(filename,dir);
	strcat(filename,"/");
	strcat(filename,dfile);
	if(pfwrite(filename,pf))
		elog_die(0,"pfwrite error for file %s\n",filename);
}
开发者ID:battistuz,项目名称:antelope_contrib,代码行数:33,代码来源:dbpmel.c

示例8: dbtable_invalid

/* This first little function returns 0 if the table defined by
the string t is a valid table name for the database pointed
to by the database pointer db.  Otherwise it returns a 1.
This allows a general way to safely check for the validity of 
extension tables to a common schema like css3.0.  General usage would be:

if(dbtable_invalid(db,t)) elog_die(0,"blah blah");

Generally this routine should be called once for a given table, but
it can be called repeatedly at the cost of efficiency.  The later
is specially bad if the table involved is hit often.  
*/
int dbtable_invalid(Dbptr db,char *t)
{
	Dbptr dbcheck;

	dbcheck = dblookup(db,0,t,0,0);
	if(dbcheck.table == dbINVALID)
		return(-1);
	else
		return(0);
}
开发者ID:EugeneGalipchak,项目名称:antelope_contrib,代码行数:22,代码来源:save_predarr.c

示例9: dbtable_empty

/* returns true if the table t is empty */
int dbtable_empty(Dbptr db,char *t)
{
	long nrows;
	db=dblookup(db,0,t,0,0);
	dbquery(db,dbRECORD_COUNT,&nrows);
	if(nrows>0) 
		return(0);
	else
		return(1);
}
开发者ID:EugeneGalipchak,项目名称:antelope_contrib,代码行数:11,代码来源:save_predarr.c

示例10: set_shot_variable

void set_shot_variable(Dbptr db, Arr *tables, int evid, SEGYTraceHeader *h)
{
	int *ok;
	char ss_string[30];
	long int ntest;
	double dnorth, deast, elev, edepth;

	ok = getarr(tables,"shot");
	if(ok)
	{
		db = dblookup(db,0,"shot",0,0);
		sprintf(ss_string,"evid == %d",evid);
		db = dbsubset(db,ss_string,0);
		dbquery(db,dbRECORD_COUNT,&ntest);
		if(ntest <= 0)
		{
			elog_complain(0,"evid %d not found in shot table\nShot coordinates will not be saved in segy headers\n",
				evid);
			dbfree(db);
			return;
		}
		else if(ntest > 1)
		{
			elog_notify(0,"multiple rows in shot found for evid %d\n",
				evid);
		}
		db.record = 0;
		if(dbgetv(db,0,
			"dnorth",&dnorth,
			"deast", &deast,
			"elev", &elev,
			"edepth",&edepth,
				NULL) == dbINVALID)
		{
			elog_complain(0,"dbgetv error for evid %d\nShot coordinates will not be saved in segy headers\n",
				evid);
			return;
		}
		/*convert to m from km */
		deast *= 1000.0;
		dnorth *= 1000.0;
		h->sourceLongOrX          = htonl((int32_t) deast);
		h->sourceLatOrY           = htonl((int32_t) dnorth);
		h->sourceSurfaceElevation = htonl((int32_t) elev);
		h->sourceDepth            = htonl((int32_t) edepth);
		/* WARNING:  This assumes receiver coordinates have already been set */
		h->sourceToRecDist = htonl( (int32_t) hypot(
					dnorth - ((double)(ntohl(h->recLatOrY ))),
					deast  - ((double)(ntohl(h->recLongOrX)))
		));
	}
	dbfree(db);
}
开发者ID:NVSeismoLab,项目名称:antelope_contrib,代码行数:53,代码来源:db2segy.c

示例11: save_origin

int save_origin(int nass, int evid, Dbptr master_db, Dbptr dbtmp,
			Hypocenter h,Location_options o, int orb)
{
	int ndef;
	char dtype[2];
        char algorithm[16]="ggnloc";
	char auth[16]="orbgenloc";
	int grn, srn;
	int orid;  /* orid returned */

	orid = dbnextid(master_db,"orid");
	if(orid  < 0 )
		elog_die(1,"save_origin:  dbnextid failure asking for new orid\n");
        if(o.fix[2])
        {
                ndef = h.degrees_of_freedom + 3;
                strcpy(dtype,"r");
        }
        else
        {
                ndef = h.degrees_of_freedom + 4;
                strcpy(dtype,"f");
        }
	grn = grnumber(h.lat, h.lon) ;
	srn = srnumber ( grn ) ;
	dbtmp = dblookup(dbtmp,0,"origin",0,0);
	dbtmp.record = dbSCRATCH;
	if((dbputv(dbtmp,0,
                "lat",h.lat,
                "lon",h.lon,
                "depth",h.z,
                "time",h.time,
                "orid",orid,
		"evid",evid,
		"nass",nass,
		"grn", grn,
		"srn", srn,
		"dtype",dtype,
		"ndef",ndef,
		"algorithm",algorithm,
		"auth",auth,0))
			 == dbINVALID)
	{
		elog_complain(0,"dbputv error while building origin record for orid %d\nNo results saved\n",
			orid);
	}
	else
	{
		if(save_dbrecord(dbtmp,orb))
			elog_complain(0,"Errors saving orid %d\n",orid);
	}
	return(orid);
}
开发者ID:EugeneGalipchak,项目名称:antelope_contrib,代码行数:53,代码来源:orbgenloc.c

示例12: save_origerr

/*This function adds a single row to the origerr table for this event.

arguements:
	orid - orid assign to this solution
	h - Hypocenter object for this solution
	dbo - output db

This version doesn't set much of this large table.  Eventually, it 
needs to include all the error terms, but that function is not 
written yet. 

Author:  Gary L. Pavlis
Written:  February 1997
*/
void save_origerr(int orid, Hypocenter h, double **C, Dbptr db, int orb)
{
	double sdobs; 
	int rc;
	double smajax,sminax,strike,sdepth,stime;
	double conf=0.683;

	db = dblookup(db,0,"origerr",0,0);
	db.record = dbSCRATCH;

	/* computer error ellipse parameters */
	rc = project_covariance(C,CHI_SQUARE,&conf,
			h.rms_weighted,h.degrees_of_freedom,
			&smajax,&sminax,&strike,&sdepth,&stime);

	/* Bad news here is that we can't save the more useful 
	statistics that this program calculates.  css3.0 only allows
	sdobs = sswr/ndgf */

	sdobs = h.rms_raw;
	if(dbputv(db,0,
		"orid",orid,
                "sxx",C[0][0],
                "syy",C[1][1],
                "szz",C[2][2],
                "stt",C[3][3],
                "sxy",C[0][1],
                "sxz",C[0][2],
                "syz",C[1][2],
                "stx",C[0][3],
                "sty",C[1][3],
                "stz",C[2][3],
		"sdobs",sdobs,
		"smajax",smajax,
		"sminax",sminax,
		"strike",strike,
		"sdepth",sdepth,
		"stime",stime,
		"conf",conf,
			0) == dbINVALID)
	{
		elog_complain(0,"save_origerr: dbputv error writing origerr record for orid %d\norigerr record not saved anywhere\n",
				orid);
	}
	else
	{
		if(save_dbrecord(db,orb))
			elog_complain(0,"Error saving origerr record for orid %d\n",
				orid);
	}

}
开发者ID:EugeneGalipchak,项目名称:antelope_contrib,代码行数:66,代码来源:orbgenloc.c

示例13: dbget

/* Initializes the scratch records for each table used in this program.  
That is, origin, origerr, and assoc.  This only needs to be done
once.  The procedure loads NULL files into each attribute of the
scratch records for these tables.  This function is based
on a tricky initialization condition using dbget.  Setting
the db record to dbNULL and then calling dbget(db,0) loads the
scratch record with the contents of the NULL record.  This works
because the NULL record is initialized the first time it is
accessed, and passing 0 to dbget is a shortcut that directly 
copies the NULL record to the scratch record.  IMPORTANT:  note
that because this program uses dbputv directly to the scratch
record the assumption is that the SAME set of attributes are
always written to the scratch record of each table.  This is
correct for this program, but you are warned if you try to use
functions from this program elsewhere.  

Arguments:  db - db pointer of open database 

returns 0 on success.  Any errors will always result in
a return of dbINVALID.  The later should, of course, be
trapped but should probably not normally be fatal.
*/
initialize_scratch_records(Dbptr db)
{
	int return_code;
	int error_count=0;

	db = dblookup(db,0,"origin",0,0);
	db.record = dbNULL;
	return_code = dbget(db,0);
	if(return_code) ++error_count;
	db = dblookup(db,0,"origerr",0,0);
	db.record = dbNULL;
	return_code = dbget(db,0);
	if(return_code) ++error_count;
	db = dblookup(db,0,"assoc",0,0);
	db.record = dbNULL;
	return_code = dbget(db,0);
	if(return_code) ++error_count;
	if(error_count)
		return(dbINVALID);
	else
		return(0);
}
开发者ID:EugeneGalipchak,项目名称:antelope_contrib,代码行数:44,代码来源:orbgenloc.c

示例14: newarr

/* This routine looks for a Tbl in the parameter space that
defines a set of auxiliary tables that are to be used.  It
cautiously checks to see if that table is defined in the
schema and is nonempty.  It sets logical variables in associative
array it returns that define if the table is "ok".  This is serious
overkill added to make the code for expandable in the future.
At the moment the only table that would be used is "shot".
It would, however, be easy to add similar auxiliary tables for
segy constructs like statics, mute definition, etc.  In that
case there probably should be a more general mechanism than this
but I'm more or less laying out a useful functionality here rather
than doing it in a completely general way.
*/
Arr *check_tables(Dbptr db, Pf *pf)
{
	char *table;
	int *ilogic;
	int i;
	Tbl *t;
	Dbptr dbtmp;
	int table_ok;
	long int nrec;
	Arr *a;

	a = newarr(0);
	t = pfget_tbl(pf,"join_tables");
	if(t == NULL)
	{
		elog_die(0,"No list of tables to be joined\n");
	}
	for(i=0;i<maxtbl(t);++i)
	{
		/* This series of conditionals is safe:  It certifies
		a table (a) is defined in this schema and (b) is
		not empty.  */
		table = (char *)gettbl(t,i);
		dbtmp = dblookup(db,0,table,0,0);
		if(dbtmp.table == dbINVALID)
			table_ok = 0;
		else
			table_ok = 1;
		if(table_ok)
		{
			dbquery(dbtmp,dbRECORD_COUNT,&nrec);
			if(nrec > 0)
				table_ok = 1;
			else
				table_ok = 0;
		}
		ilogic = (int *) malloc(sizeof(int));
		if(ilogic == NULL) elog_die(0,"malloc error\n");
		*ilogic = table_ok;
		setarr(a,table,ilogic);
	}
	return(a);
}
开发者ID:NVSeismoLab,项目名称:antelope_contrib,代码行数:56,代码来源:db2segy.c

示例15: save_event

/* Changed to int from void by JN in order to return evid. */
long save_event(Dbptr dbi, long is, long ie, long orid, Dbptr dbo)

{
	/* these are variables in dbi copied to dbo */
	long evid;
	char evname[16];
	
	/*altered in output by this program */
	long prefor;
	char auth[20];
	double lddate;

	/* intentionally ignored:  commid */

	dbo = dblookup(dbo,0,"event",0,0);
	dbi.record = is;
	if( dbgetv(dbi,0,
		"event.evid",&evid,
		"event.evname",evname,	
				NULL) == dbINVALID)
	{
		elog_die(1,"save_event: dbgetv error reading event fields of input view at record %ld\n",
				is);
	}
	prefor = orid;
	my_username(auth);
	lddate = std_now();
	if(dbaddv(dbo,0,
                "evid",evid,
		"evname",evname,
		"prefor",prefor,
                "auth",auth,
                "lddate",lddate,
			NULL ) == dbINVALID)
	{
		elog_die(1,"save_event: dbaddv error writing event record for orid %ld\n",
				orid);
	}
        /* Added by JN */
	return(evid);
}
开发者ID:antelopeusersgroup,项目名称:antelope_contrib,代码行数:42,代码来源:relocate.c


注:本文中的dblookup函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。