@@ -15,6 +15,8 @@ public class DataAccessor : ISavedQueryDatabaseAccessor
1515 private string _connectionString ;
1616
1717 private string _savedQueryTableOwner ;
18+
19+ private string _savedQueryTableName ;
1820
1921 public DataAccessor ( )
2022 {
@@ -30,6 +32,12 @@ public DataAccessor()
3032 throw new System . Configuration . ConfigurationErrorsException ( "AppSetting SavedQueryTableOwner not set in config file" ) ;
3133 }
3234 _savedQueryTableOwner = System . Configuration . ConfigurationManager . AppSettings [ "SavedQueryTableOwner" ] ;
35+
36+ if ( string . IsNullOrWhiteSpace ( System . Configuration . ConfigurationManager . AppSettings [ "SavedQueryTableName" ] ) )
37+ {
38+ throw new System . Configuration . ConfigurationErrorsException ( "AppSetting SavedQueryTableName not set in config file" ) ;
39+ }
40+ _savedQueryTableName = System . Configuration . ConfigurationManager . AppSettings [ "SavedQueryTableName" ] ;
3341 }
3442
3543 public PCAxis . Query . SavedQuery Load ( int id )
@@ -38,7 +46,7 @@ public PCAxis.Query.SavedQuery Load(int id)
3846 {
3947 conn . Open ( ) ;
4048
41- var cmd = new OracleCommand ( "select QueryText from " + _savedQueryTableOwner + ".SavedQueryMeta where QueryId = :queryId" , conn ) ;
49+ var cmd = new OracleCommand ( "select QueryText from " + _savedQueryTableOwner + "." + _savedQueryTableName + " where QueryId = :queryId", conn ) ;
4250 cmd . Parameters . Add ( "queryId" , id ) ;
4351 string query = cmd . ExecuteScalar ( ) as string ;
4452
@@ -58,7 +66,7 @@ public int Save(PCAxis.Query.SavedQuery query, int? id = null)
5866 {
5967 string insertSQL = @"BEGIN
6068 insert into
61- {3}.SavedQueryMeta
69+ {3}.{4}
6270 (
6371 {0}
6472 DataSourceType,
@@ -107,7 +115,7 @@ insert into
107115 returningPart = "" ;
108116 }
109117
110- insertSQL = string . Format ( insertSQL , queryIdPartCol , queryIdPartValue , returningPart , _savedQueryTableOwner ) ;
118+ insertSQL = string . Format ( insertSQL , queryIdPartCol , queryIdPartValue , returningPart , _savedQueryTableOwner , _savedQueryTableName ) ;
111119
112120 conn . Open ( ) ;
113121 var cmd = new OracleCommand ( insertSQL , conn ) ;
@@ -145,7 +153,7 @@ public bool MarkAsRunned(int id)
145153 using ( var conn = new OracleConnection ( _connectionString ) )
146154 {
147155 conn . Open ( ) ;
148- var cmd = new OracleCommand ( "update " + _savedQueryTableOwner + ".SavedQueryMeta set UsedDate = sysdate, Runs = Runs + 1 where QueryId = :queryId" , conn ) ;
156+ var cmd = new OracleCommand ( "update " + _savedQueryTableOwner + "." + _savedQueryTableName + " set UsedDate = sysdate, Runs = Runs + 1 where QueryId = :queryId", conn ) ;
149157 cmd . Parameters . Add ( "queryId" , id ) ;
150158
151159 return cmd . ExecuteNonQuery ( ) == 1 ;
@@ -159,7 +167,7 @@ public bool MarkAsFailed(int id)
159167 using ( var conn = new OracleConnection ( _connectionString ) )
160168 {
161169 conn . Open ( ) ;
162- var cmd = new OracleCommand ( "update " + _savedQueryTableOwner + ".SavedQueryMeta set UsedDate = sysdate, Runs = Runs + 1, Fails = Fails + 1 where QueryId = :queryId" , conn ) ;
170+ var cmd = new OracleCommand ( "update " + _savedQueryTableOwner + "." + _savedQueryTableName + " set UsedDate = sysdate, Runs = Runs + 1, Fails = Fails + 1 where QueryId = :queryId", conn ) ;
163171 cmd . Parameters . Add ( "queryId" , id ) ;
164172
165173 return cmd . ExecuteNonQuery ( ) == 1 ;
0 commit comments