#include #include #include "SDDAS_types.h" #include "libdb.h" #ifdef ALL_DB #include "libserverWrap.h" #endif #include "local.h" char *dbVirtualNameWithQuery (SDDAS_ULONG data_key) { char query_str [1024]; DB_RESULT *result; DB_ROW row; static SDDAS_ULONG _last_data_key = 0; static char _vinst [MAX_IDFS_VIRT_NAME]; if (data_key != _last_data_key) { sprintf (query_str, "SELECT 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 (_vinst, row [0]); } dbFreeResult (result); _last_data_key = data_key; } } #ifdef ALL_DB if (data_key == 0) { char *vinst = SwRI_dbVirtualName (data_key); if (vinst != NULL) { strcpy (_vinst, vinst); _last_data_key = data_key; } } #endif return (_vinst); } /* Returns a 1 on success */ int dbVirtualNameWithQuery_r (SDDAS_ULONG data_key, char *vinst, int len) { char query_str [1024]; DB_RESULT *result; DB_ROW row; int err = 1; sprintf (query_str, "SELECT virtual "\ "FROM hierarchy WHERE data_key=%ld;", (long) data_key); if ((result = (DB_RESULT *) dbQueryStore (query_str)) != NULL) { while ((row = (DB_ROW) dbFetchRow (result))) { strncpy (vinst, row [0], len); } dbFreeResult (result); } else err = 0; #ifdef ALL_DB if (data_key == 0) { err = SwRI_dbVirtualName_r (data_key, vinst, len); } #endif return (err); }