📄 queryupdateset.java
字号:
/*
LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
Copyright (C) 2003 Together
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.webdocwf.util.loader;
import java.util.*;
import java.sql.*;
/**
*
* QueryUpdateSet class creates the update sql statement
* @author Radoslav Dutina
* @version 1.0
*/
public class QueryUpdateSet {
private String strQueryUpdate=null;
private Vector indexDummyOverwrite=new Vector();
// private Vector indexDummyUpdate=new Vector();
private Vector indexDummySetNull=new Vector();
private String versionName="version";
/**
* Construct the object of QueryUpdateSet class with associated parameter
* @param vecColumnNames is vector which contain column names
* @param vecColumnTypes is vector which contain column types
* @param vecColumnMode is vector which contain column mode
* @param tableName is the current table name
* @param oid is boolean parameter
*/
public QueryUpdateSet(Vector vecColumnNames, Vector vecColumnTypes, Vector vecColumnMode,
String tableName, boolean oid, String versionName, ConfigReader configReaderTarget) throws LoaderException {
this.versionName=versionName;
this.strQueryUpdate=strQueryUpdate;
strQueryUpdate="update " + tableName + " set ";
int counter=0;
for (int j = 0; j < vecColumnNames.size(); j++) {
counter=j;
if (vecColumnMode.get(j).toString().equalsIgnoreCase("Overwrite")) {
indexDummyOverwrite.add(String.valueOf(counter));
strQueryUpdate+=vecColumnNames.get(j).toString()+"=";
//ZK change this 7.5.3004 from CheckType to configReaderSource
try {
//ZK Added next line because of DB2 type LONG VARCHAR
String columnType = Utils.replaceAll(vecColumnTypes.get(j).toString()," ","_");
if(!configReaderTarget.isNumber(columnType)){
strQueryUpdate+="'dummyOverwrite'"+", ";
}else{
strQueryUpdate+="dummyOverwrite"+", ";
}
} catch (LoaderException e) {
LoaderException le = new LoaderException("Exception:Type not present in conf file for target database, add it into conf file.",(Throwable)e);
throw le;
}
}else if (vecColumnMode.get(j).toString().equalsIgnoreCase("SetNull")) {
strQueryUpdate +="dummySetNull"+", ";
indexDummySetNull.add(String.valueOf(counter));
}
}
if(oid)
strQueryUpdate += " "+this.versionName+" = " + "dummyVersionOverwrite" + " where ";
else{
int start=strQueryUpdate.lastIndexOf(",");
if(start<strQueryUpdate.length()-1&&start!=-1)
strQueryUpdate=strQueryUpdate.substring(0,strQueryUpdate.lastIndexOf(","));
strQueryUpdate += " where ";
}
}
/**
* This method read the value of strQueryUpdate parameter
* @return value of parameter
*/
public String getQueryUpdate(){
return this.strQueryUpdate ;
}
/**
* This method read the value of indexDummyOverwrite parameter
* @return value of parameter
*/
public Vector getIndexDummyOverwrite(){
return indexDummyOverwrite;
}
/**
* This method read the value of indexDummySetNull parameter
* @return value of parameter
*/
public Vector getIndexDummySetNull(){
return indexDummySetNull;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -