package com.changhong.autoform.entity.sql.update;
|
|
import java.util.Map;
|
import java.util.Map.Entry;
|
import java.util.Set;
|
|
import com.changhong.autoform.entity.sql.Sql;
|
|
public class UpdateTable extends Sql{
|
|
private String tableName;
|
|
private Map<String, Object> fields;
|
|
public UpdateTable(String tableName, Map<String, Object> fields) {
|
super(tableName, fields);
|
this.tableName = tableName;
|
this.fields = fields;
|
}
|
|
@Override
|
public String getSql() {
|
StringBuilder sql = new StringBuilder();
|
sql.append(" ALTER TABLE ").append(getTableName());
|
Set<Entry<String, Object>> entrySet = fields.entrySet();
|
if(entrySet.size()> 0) {
|
for (Entry<String, Object> entry : entrySet) {
|
sql.append(" ADD COLUMN ")
|
.append(entry.getKey() )
|
.append(" "+entry.getValue())
|
.append(" NULL AFTER PARENTDATAROWNUM")
|
.append(',');
|
|
}
|
sql.deleteCharAt(sql.length()-1);
|
}
|
sql.append(";");
|
int i = 0;
|
return sql.toString();
|
}
|
|
@Override
|
public Object[] getParams() {
|
Object[] arr = new Object[]{};
|
return arr;
|
}
|
|
public Map<String, Object> getFields() {
|
return fields;
|
}
|
|
public void setFields(Map<String, Object> fields) {
|
this.fields = fields;
|
}
|
|
public String getTableName() {
|
return tableName;
|
}
|
|
public void setTableName(String tableName) {
|
this.tableName = tableName;
|
}
|
|
}
|