public void visit(Insert obj) { visitNode(obj.getTable()); visitNodes(obj.getColumns()); if (!(obj.getValueSource() instanceof QueryExpression) || visitSubcommands) { visitNode(obj.getValueSource()); } }
public void visit(Insert obj) { if (obj.isUpsert()) { buffer.append(getUpsertKeyword()).append(Tokens.SPACE); } else { buffer.append(getInsertKeyword()).append(Tokens.SPACE); } appendSourceComment(obj); buffer.append(INTO).append(Tokens.SPACE); append(obj.getTable()); buffer.append(Tokens.SPACE).append(Tokens.LPAREN); this.shortNameOnly = true; append(obj.getColumns()); this.shortNameOnly = false; buffer.append(Tokens.RPAREN); buffer.append(Tokens.SPACE); append(obj.getValueSource()); }
@Override public void visit(Insert obj) { visit(obj.getTable()); for (ColumnReference cr : obj.getColumns()) { visit(cr); createProjectedColumn(false); } if (!(obj.getValueSource() instanceof ExpressionValueSource)) { throw new AssertionError(); } for (Expression ex : ((ExpressionValueSource)obj.getValueSource()).getValues()) { if (!(ex instanceof Literal)) { throw new AssertionError(); } } }
@Override public void visit(Insert obj) { visitNode(obj.getTable()); visitNodes(obj.getColumns()); if (!(obj.getValueSource() instanceof QueryExpression) && obj.getParameterValues() == null) { visitNode(obj.getValueSource()); } else { // bulk insert values this.values = obj.getParameterValues(); } }
@Override public void visit(Insert obj) { this.method = "POST"; //$NON-NLS-1$ this.entity = obj.getTable().getMetadataObject(); this.uri = this.entity.getName(); final List<OProperty<?>> props = new ArrayList<OProperty<?>>(); int elementCount = obj.getColumns().size(); for (int i = 0; i < elementCount; i++) { Column column = obj.getColumns().get(i).getMetadataObject(); List<Expression> values = ((ExpressionValueSource)obj.getValueSource()).getValues(); OProperty<?> property = readProperty(column, values.get(i)); props.add(property); } this.payload = props; }
private void buildSingleRowInsertPayload(Insert insert, DataPayload data) throws TranslatorException { List<ColumnReference> columns = insert.getColumns(); List<Expression> values = ((ExpressionValueSource)insert.getValueSource()).getValues(); if(columns.size() != values.size()) { throw new TranslatorException(SalesForcePlugin.Util.gs(SalesForcePlugin.Event.TEIID13006)); } for(int i = 0; i < columns.size(); i++) { Column column = columns.get(i).getMetadataObject(); Object value = values.get(i); if(!(value instanceof Literal)) { throw new TranslatorException(SalesForcePlugin.Util.gs(SalesForcePlugin.Event.TEIID13007)); } Literal literalValue = (Literal)values.get(i); Object val = literalValue.getValue(); if (val instanceof Timestamp) { Calendar cal = Calendar.getInstance(); cal.setTime((Timestamp)val); val = cal; } data.addField(column.getSourceName(), val); } }
public void testGetValues() throws Exception { Insert insert = example("a.b"); //$NON-NLS-1$ assertNotNull(insert.getValueSource()); assertEquals(4, ((ExpressionValueSource)insert.getValueSource()).getValues().size()); for (Iterator i = ((ExpressionValueSource)insert.getValueSource()).getValues().iterator(); i.hasNext();) { assertTrue(i.next() instanceof Expression); } }
@Override public void visit(Insert obj) { this.operationType = OperationType.INSERT; visitNode(obj.getTable()); try { // read the properties int elementCount = obj.getColumns().size(); for (int i = 0; i < elementCount; i++) { Column column = obj.getColumns().get(i).getMetadataObject(); List<Expression> values = ((ExpressionValueSource)obj.getValueSource()).getValues(); Expression expr = values.get(i); Object value = resolveExpressionValue(expr); this.odataQuery.addInsertProperty(column, ODataMetadataProcessor.getNativeType(column), value); } } catch (TranslatorException e) { this.exceptions.add(e); } }
List<ColumnReference> columns = insert.getColumns(); int boundCount = 0; List<Expression> literalValues = ((ExpressionValueSource)insert.getValueSource()).getValues(); while (it.hasNext()) { if (boundCount >= rowCount) {
public void testExpressionsInInsert() throws Exception { Insert insert = example2("a.b"); //$NON-NLS-1$ assertNotNull(insert.getColumns()); assertEquals(1, insert.getColumns().size()); for (Iterator i = insert.getColumns().iterator(); i.hasNext();) { assertTrue(i.next() instanceof ColumnReference); } assertNotNull(insert.getValueSource()); assertEquals(1, ((ExpressionValueSource)insert.getValueSource()).getValues().size()); for (Iterator i = ((ExpressionValueSource)insert.getValueSource()).getValues().iterator(); i.hasNext();) { assertTrue(i.next() instanceof Expression); } }
List<Expression> values = ((ExpressionValueSource)obj.getValueSource()).getValues();
if (!(insert.getValueSource() instanceof ExpressionValueSource)) { return; ExpressionValueSource values = (ExpressionValueSource)insert.getValueSource(); if (insert.getTable().getMetadataObject() == null) { return;
private void handleInsert() throws TranslatorException { Insert insert = (Insert)command; ExpressionValueSource evs = (ExpressionValueSource)insert.getValueSource(); Row row = nextRow(); Sheet sheet = null; if (row == null) { sheet = workbook.getSheet(this.visitor.getSheetName()); } else { sheet = row.getSheet(); } int last = sheet.getLastRowNum(); Row newRow = sheet.createRow(last+1); List<Integer> cols = this.visitor.getProjectedColumns(); for (int i = 0; i < cols.size(); i++) { int index = cols.get(i); setValue(newRow, index-1, ((Literal)evs.getValues().get(i)).getValue()); } if (executionContext.getCommandContext().isReturnAutoGeneratedKeys()) { GeneratedKeys keys = executionContext.getCommandContext().returnGeneratedKeys(new String[] {ExcelMetadataProcessor.ROW_ID}, new Class<?>[] {TypeFacility.RUNTIME_TYPES.INTEGER}); keys.addKey(Arrays.asList(last+1)); } result++; writeXLSFile(); }
public void visit(Insert obj) { worksheetTitle = obj.getTable().getName(); if (obj.getTable().getMetadataObject().getNameInSource() != null) { worksheetTitle = obj.getTable().getMetadataObject().getNameInSource(); } worksheetKey = info.getWorksheetByName(worksheetTitle).getId(); ExpressionValueSource evs = (ExpressionValueSource)obj.getValueSource(); for (int i = 0; i < evs.getValues().size(); i++) { Expression e = evs.getValues().get(i); if (!(e instanceof Literal)) { throw new SpreadsheetOperationException("Only literals are allowed in the values section"); } Literal l = (Literal)e; if (l.getValue() == null) { continue; } ColumnReference columnReference = obj.getColumns().get(i); columnNameValuePair.put(columnReference.getMetadataObject().getSourceName(), l.getValue()); } }
List<Expression> values = ((ExpressionValueSource)insert.getValueSource()).getValues(); if(columns.size() != values.size()) { throw new TranslatorException(JPAPlugin.Util.gs(JPAPlugin.Event.TEIID14007));
if (command instanceof Insert) { Insert insert = (Insert)command; if (insert.getValueSource() instanceof QueryExpression) { QueryExpression qe = (QueryExpression)insert.getValueSource(); if (qe.getWith() != null) { With with = qe.getWith();
List<Expression> insertValueList = ((ExpressionValueSource)((Insert)command).getValueSource()).getValues();