public static string DetermineIfSqlHandleOrSqlQuery(string sqlHandleOrString) { // Should be modified when more clever object store is implemented if (PersistentObjects.ContainsKey(sqlHandleOrString, "SQL")) { return(PersistentObjects.GetFromMap <string>(sqlHandleOrString, "SQL")); } else { return(sqlHandleOrString); } }
public static string fUtilityQueryDataTable(string handle, string sqlStringOrHandle) { PersistentObjects.AssertReservedWordsTableName(handle); string sql = ObjectInfo.DetermineIfSqlHandleOrSqlQuery(sqlStringOrHandle); var tableHandle = ParsingFunctionality.GetTableNameFromSqlQuery(sql); if (PersistentObjects.ContainsKey(tableHandle, "DATATABLE") == false) { return("ERROR: DataTable + " + tableHandle + " does not exist in the object map."); } else { var newTable = QueryCSV.QueryDataTable(sql, PersistentObjects.CsvPath); newTable.TableName = handle; PersistentObjects.AddToMap(handle, newTable, "DATATABLE"); return(handle); } }
public static object[,] fUtilityQueryDataTable(string sqlStringOrHandle, object noHeadersInput) { string sql = ObjectInfo.DetermineIfSqlHandleOrSqlQuery(sqlStringOrHandle); object[,] output; bool noHeaders = Optional.Check(noHeadersInput, false); var tableHandle = ParsingFunctionality.GetTableNameFromSqlQuery(sql); if (PersistentObjects.ContainsKey(tableHandle, "DATATABLE") == false) { string errorMessage = "ERROR: DataTable + " + tableHandle + " does not exist in the object map."; output = new object[1, 1]; output[0, 0] = errorMessage; return(output); } else { var newTable = QueryCSV.QueryDataTable(sql, PersistentObjects.CsvPath); output = ExcelFriendlyConversion.ConvertDataTableToObjectArray(newTable, noHeaders); return(output); } }