Commits

tbrugz committed 6470ea6

sqldump/queries: added 'replace' strings parameters ; example for 'param's in sqlqueries

Comments (0)

Files changed (3)

sqldump.template.properties

 #sqldump.queries=table_x, q2, partitiontest
 
 #sqldump.query.table_x.sql=\
-#select * from TABLE_X
+#select * from TABLE_X where abc=?
 #sqldump.query.table_x.name=TABLE_X
 #sqldump.query.table_x.rowlimit=10000
 #sqldump.query.table_x.keycols=ID
+#sqldump.query.table_x.param.1=3
 
 #sqldump.query.q2.sqlfile=c:/xxx/query2.sql
 #sqldump.query.q2.name=query_2
 #sqldump.query.q2.keycols=ID, PARENT_ID
+# replaces '${sqldump.query.replace.<1-n>}' in sql statement by value of 'sqldump.query.<query-id>.replace.<1-n>'
+#sqldump.query.q2.replace.1=2011
 #sqldump.datadump.outfilepattern.id@q2=${outputdir}/data_q2_${tablename}.${syntaxfileext}
 
 #sqldump.query.partitiontest.name=partition_test

src/tbrugz/sqldump/datadump/DataDump.java

 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import tbrugz.sqldump.SQLUtils;
 import tbrugz.sqldump.dbmodel.Constraint;
 import tbrugz.sqldump.dbmodel.Table;
 import tbrugz.sqldump.dbmodel.TableType;
 			}
 			
 			long initTime = System.currentTimeMillis();
+			logRow.info("[qid="+tableOrQueryId+"] running query '"+tableOrQueryName+"'");
 			ResultSet rs = st.executeQuery();
 			ResultSetMetaData md = rs.getMetaData();
 			

src/tbrugz/sqldump/datadump/SQLQueries.java

 		int i=0;
 		for(String qid: queriesArr) {
 			qid = qid.trim();
+			//replace strings
+			int replaceCount = 1;
+			//List<String> replacers = new ArrayList<String>();
+			while(true) {
+				String paramStr = prop.getProperty("sqldump.query."+qid+".replace."+replaceCount);
+				if(paramStr==null) { break; }
+				prop.setProperty("sqldump.query.replace."+replaceCount, paramStr);
+				//replacers.add(paramStr);
+				replaceCount++;
+			}
+			//sql string
 			String sql = prop.getProperty("sqldump.query."+qid+".sql");
 			if(sql==null) {
 				//load from file