use of org.pentaho.di.core.SQLStatement in project pentaho-kettle by pentaho.
the class DimensionLookupDialog method create.
// Generate code for create table...
// Conversions done by Database
// For Sybase ASE: don't keep everything in lowercase!
private void create() {
try {
DimensionLookupMeta info = new DimensionLookupMeta();
getInfo(info);
// new name might not yet be linked to other
String name = stepname;
// steps!
StepMeta stepinfo = new StepMeta(BaseMessages.getString(PKG, "DimensionLookupDialog.Stepinfo.Title"), name, info);
RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
String message = null;
if (Utils.isEmpty(info.getKeyField())) {
message = BaseMessages.getString(PKG, "DimensionLookupDialog.Error.NoTechnicalKeySpecified");
}
if (Utils.isEmpty(info.getTableName())) {
message = BaseMessages.getString(PKG, "DimensionLookupDialog.Error.NoTableNameSpecified");
}
if (message == null) {
SQLStatement sql = info.getSQLStatements(transMeta, stepinfo, prev, repository, metaStore);
if (!sql.hasError()) {
if (sql.hasSQL()) {
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(), sql.getSQL());
sqledit.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "DimensionLookupDialog.NoSQLNeeds.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "DimensionLookupDialog.NoSQLNeeds.DialogTitle"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(sql.getError());
mb.setText(BaseMessages.getString(PKG, "DimensionLookupDialog.SQLError.DialogTitle"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(message);
mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
mb.open();
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "DimensionLookupDialog.UnableToBuildSQLError.DialogMessage"), BaseMessages.getString(PKG, "DimensionLookupDialog.UnableToBuildSQLError.DialogTitle"), ke);
}
}
use of org.pentaho.di.core.SQLStatement in project pentaho-kettle by pentaho.
the class LucidDBStreamingLoaderMeta method getSQLStatements.
@Override
public SQLStatement getSQLStatements(TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev, Repository repository, IMetaStore metaStore) throws KettleStepException {
SQLStatement retval = super.getSQLStatements(transMeta, stepMeta, prev, repository, metaStore);
if (databaseMeta != null) {
if (prev != null && prev.size() > 0) {
String schemaTable = databaseMeta.getQuotedSchemaTableCombination(transMeta.environmentSubstitute(schemaName), transMeta.environmentSubstitute(tableName));
if (!Utils.isEmpty(schemaTable)) {
Database db = new Database(loggingObject, databaseMeta);
db.shareVariablesWith(transMeta);
try {
db.connect();
String cr_table = db.getDDL(schemaTable, prev);
// Empty string means: nothing to do: set it to null...
if (cr_table == null || cr_table.length() == 0) {
cr_table = null;
}
retval.setSQL(cr_table);
} catch (KettleDatabaseException dbe) {
retval.setError(BaseMessages.getString(PKG, "LucidDBStreamingLoaderMeta.Error.ErrorConnecting", dbe.getMessage()));
} finally {
db.disconnect();
}
} else {
retval.setError(BaseMessages.getString(PKG, "LucidDBStreamingLoaderMeta.Error.NoTable"));
}
} else {
retval.setError(BaseMessages.getString(PKG, "LucidDBStreamingLoaderMeta.Error.NoInput"));
}
} else {
retval.setError(BaseMessages.getString(PKG, "LucidDBStreamingLoaderMeta.Error.NoConnection"));
}
return retval;
}
use of org.pentaho.di.core.SQLStatement in project pentaho-kettle by pentaho.
the class GPBulkLoaderDialog method create.
// Generate code for create table...
// Conversions done by Database
private void create() {
try {
GPBulkLoaderMeta info = new GPBulkLoaderMeta();
getInfo(info);
// new name might not yet be linked to other steps!
String name = stepname;
StepMeta stepMeta = new StepMeta(BaseMessages.getString(PKG, "GPBulkLoaderDialog.StepMeta.Title"), name, info);
RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
SQLStatement sql = info.getSQLStatements(transMeta, stepMeta, prev, repository, metaStore);
if (!sql.hasError()) {
if (sql.hasSQL()) {
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(), sql.getSQL());
sqledit.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "GPBulkLoaderDialog.NoSQLNeeds.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "GPBulkLoaderDialog.NoSQLNeeds.DialogTitle"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(sql.getError());
mb.setText(BaseMessages.getString(PKG, "GPBulkLoaderDialog.SQLError.DialogTitle"));
mb.open();
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "GPBulkLoaderDialog.CouldNotBuildSQL.DialogTitle"), BaseMessages.getString(PKG, "GPBulkLoaderDialog.CouldNotBuildSQL.DialogMessage"), ke);
}
}
use of org.pentaho.di.core.SQLStatement in project pentaho-kettle by pentaho.
the class GPLoadDialog method create.
// Generate code for create table...
// Conversions done by Database
private void create() {
try {
GPLoadMeta info = new GPLoadMeta();
getInfo(info);
// new name might not yet be linked to other
String name = stepname;
// steps!
StepMeta stepMeta = new StepMeta(BaseMessages.getString(PKG, "GPLoadDialog.StepMeta.Title"), name, info);
RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
SQLStatement sql = info.getSQLStatements(transMeta, stepMeta, prev, repository, metaStore);
if (!sql.hasError()) {
if (sql.hasSQL()) {
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(), sql.getSQL());
sqledit.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "GPLoadDialog.NoSQLNeeds.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "GPLoadDialog.NoSQLNeeds.DialogTitle"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(sql.getError());
mb.setText(BaseMessages.getString(PKG, "GPLoadDialog.SQLError.DialogTitle"));
mb.open();
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "GPLoadDialog.CouldNotBuildSQL.DialogTitle"), BaseMessages.getString(PKG, "GPLoadDialog.CouldNotBuildSQL.DialogMessage"), ke);
}
}
use of org.pentaho.di.core.SQLStatement in project pentaho-kettle by pentaho.
the class IngresVectorwiseLoaderDialog method sql.
private void sql() {
try {
IngresVectorwiseLoaderMeta info = new IngresVectorwiseLoaderMeta();
getInfo(info);
RowMetaInterface prev = transMeta.getPrevStepFields(stepname);
StepMeta stepMeta = transMeta.findStep(stepname);
// Only use the fields that were specified.
//
RowMetaInterface prevNew = new RowMeta();
for (int i = 0; i < info.getFieldDatabase().length; i++) {
ValueMetaInterface insValue = prev.searchValueMeta(info.getFieldStream()[i]);
if (insValue != null) {
ValueMetaInterface insertValue = insValue.clone();
insertValue.setName(info.getFieldDatabase()[i]);
prevNew.addValueMeta(insertValue);
} else {
throw new KettleStepException(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.FailedToFindField.Message", info.getFieldStream()[i]));
}
}
prev = prevNew;
SQLStatement sql = info.getSQLStatements(transMeta, stepMeta, prev, repository, metaStore);
if (!sql.hasError()) {
if (sql.hasSQL()) {
SQLEditor sqledit = new SQLEditor(transMeta, shell, SWT.NONE, info.getDatabaseMeta(), transMeta.getDbCache(), sql.getSQL());
sqledit.open();
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
mb.setMessage(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.NoSQL.DialogMessage"));
mb.setText(BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.NoSQL.DialogTitle"));
mb.open();
}
} else {
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
mb.setMessage(sql.getError());
mb.setText(BaseMessages.getString(PKG, "System.Dialog.Error.Title"));
mb.open();
}
} catch (KettleException ke) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.BuildSQLError.DialogTitle"), BaseMessages.getString(PKG, "IngresVectorWiseLoaderDialog.BuildSQLError.DialogMessage"), ke);
}
}
Aggregations