#include #include #include /* for memset */ #include "SDDAS_types.h" #include "libdb.h" #ifdef ALL_DB #include "libserverWrap.h" #endif #include "local.h" SDDAS_ULONG dbGetDataKeyWithQuery (char *p, char *m, char *e, char *i, char *v) { char query_str [1024]; DB_RESULT *result; DB_ROW row; SDDAS_ULONG data_key = 0; memset (query_str, 0, sizeof (query_str)); sprintf (query_str, "SELECT data_key FROM hierarchy WHERE project='%s' "\ "AND mission='%s' AND experiment='%s' AND "\ "instrument='%s' AND virtual='%s';", p, m, e, i, v); if ((result = (DB_RESULT *) dbQueryStore (query_str)) != NULL) { while ((row = (DB_ROW) dbFetchRow (result))) { data_key = (SDDAS_ULONG) atoi (row [0]); } } dbFreeResult (result); #ifdef ALL_DB /* if we got here and have a zero, maybe we have an SCF, fall back to the old way! */ if (data_key == 0) { data_key = SwRI_dbGetDataKey (p, m, e, i, v); } #endif return (data_key); }