#include #include #include "SDDAS_types.h" #include "libdb.h" char *dbHierarchyString (SDDAS_ULONG data_key) { static char query_str [1024]; DB_RESULT *result; DB_ROW row; static SDDAS_ULONG _last_data_key = 0; static char _project [MAX_IDFS_NAME], _mission [MAX_IDFS_NAME], _experiment [MAX_IDFS_NAME], _instrument [MAX_IDFS_NAME], _vinst [MAX_IDFS_VIRT_NAME]; if (data_key != _last_data_key) { sprintf (query_str, "SELECT project, mission, experiment, instrument, virtual "\ "FROM hierarchy WHERE data_key=%ld;", (long) data_key); if ((result = (DB_RESULT *) dbQueryStore (query_str)) != NULL) { while ((row = (DB_ROW) dbFetchRow (result))) { strcpy (_project, row [0]); strcpy (_mission, row [1]); strcpy (_experiment, row [2]); strcpy (_instrument, row [3]); strcpy (_vinst, row [4]); } dbFreeResult (result); } } sprintf (query_str, "%s/%s/%s/%s/%s", _project, _mission, _experiment, _instrument, _vinst); return (query_str); }