public void visit(SetClause clause) { shortNameOnly = true; append(clause.getSymbol()); shortNameOnly = false; buffer.append(Tokens.SPACE).append(Tokens.EQ).append(Tokens.SPACE); append(clause.getValue()); }
@Override public void visit(SetClause obj) { Column column = obj.getSymbol().getMetadataObject(); if (obj.getValue() instanceof Literal){ try { Literal l = (Literal) obj.getValue(); this.attributes.put(SimpleDBMetadataProcessor.getName(column), SimpleDBDataTypeManager.convertToSimpleDBType(l.getValue(), column.getJavaType())); } catch (TranslatorException e) { this.exceptions.add(e); } } else if (obj.getValue() instanceof Array) { try { Array array = (Array)obj.getValue(); String[] result = SimpleDBInsertVisitor.getValuesArray(array); this.attributes.put(SimpleDBMetadataProcessor.getName(column), result); } catch (TranslatorException e) { this.exceptions.add(e); } } else { this.exceptions.add(new TranslatorException(SimpleDBPlugin.Event.TEIID24001, SimpleDBPlugin.Util.gs(SimpleDBPlugin.Event.TEIID24001))); } }
@Override public void visit(SetClause obj) { visitNode(obj.getSymbol()); visitNode(obj.getValue()); }
@Override public void visit(SetClause clause) { visit(clause.getSymbol()); createProjectedColumn(false); if (!(clause.getValue() instanceof Literal)) { this.exceptions.add(new TranslatorException(ExcelPlugin.Event.TEIID23010, ExcelPlugin.Util.gs(ExcelPlugin.Event.TEIID23010, clause))); } }
private void handleUpdate() throws TranslatorException { Update update = (Update)command; List<SetClause> changes = update.getChanges(); while (true) { Row row = nextRow(); if (row == null) { break; } for (int i = 0; i < this.visitor.getProjectedColumns().size(); i++) { int index = this.visitor.getProjectedColumns().get(i); Object o = ((Literal)changes.get(i).getValue()).getValue(); setValue(row, index-1, o); } modified = true; result++; } }
@Override public void visit(Update obj) { this.method = "PUT"; //$NON-NLS-1$ this.entity = obj.getTable().getMetadataObject(); visitNode(obj.getTable()); // only pk are allowed, no other criteria not allowed obj.setWhere(buildEntityKey(obj.getWhere())); // this will build with entity keys this.uri = getEnitityURL(); if (this.uri.indexOf('(') == -1) { this.exceptions.add(new TranslatorException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17011, this.filter.toString()))); } if (this.filter.length() > 0) { this.exceptions.add(new TranslatorException(ODataPlugin.Util.gs(ODataPlugin.Event.TEIID17009, this.filter.toString()))); } final List<OProperty<?>> props = new ArrayList<OProperty<?>>(); int elementCount = obj.getChanges().size(); for (int i = 0; i < elementCount; i++) { Column column = obj.getChanges().get(i).getSymbol().getMetadataObject(); OProperty<?> property = readProperty(column, obj.getChanges().get(i).getValue()); props.add(property); } this.payload = props; }
@Override public void visit(Update obj) { this.operationType = OperationType.UPDATE; visitNode(obj.getTable()); this.odataQuery.setCondition(obj.getWhere()); try { // read the properties int elementCount = obj.getChanges().size(); for (int i = 0; i < elementCount; i++) { Column column = obj.getChanges().get(i).getSymbol().getMetadataObject(); String type = ODataTypeManager.odataType(column) .getFullQualifiedName().getFullQualifiedNameAsString(); Expression expr = obj.getChanges().get(i).getValue(); Object value = resolveExpressionValue(expr); this.odataQuery.addUpdateProperty(column, type, value); } } catch (TranslatorException e) { this.exceptions.add(e); } }
for (SetClause set : update.getChanges()) { cols.add(set.getSymbol()); vals.add(set.getValue());
@Override protected int processIds(String[] ids, IQueryProvidingVisitor visitor) throws TranslatorException { List<DataPayload> updateDataList = new ArrayList<DataPayload>(); for (int i = 0; i < ids.length; i++) { DataPayload data = new DataPayload(); for (SetClause clause : ((Update)command).getChanges()) { ColumnReference element = clause.getSymbol(); Column column = element.getMetadataObject(); String val = ((Literal) clause.getValue()).toString(); data.addField(column.getSourceName(), Util.stripQutes(val)); } data.setType(visitor.getTableName()); data.setID(ids[i]); updateDataList.add(data); } return getConnection().update(updateDataList); } }
Expression rightExpr = setClause.getValue(); if (!(rightExpr instanceof Literal) && !(rightExpr instanceof org.teiid.language.Array)) { final String msg = LDAPPlugin.Util.getString("LDAPUpdateExecution.valueNotLiteralError",nameLeftElement); //$NON-NLS-1$
public void visit(Update obj) { worksheetTitle = obj.getTable().getName(); changes = new ArrayList<UpdateSet>(); String columnName; if (obj.getTable().getMetadataObject().getNameInSource() != null) { this.worksheetTitle = obj.getTable().getMetadataObject().getNameInSource(); } for (SetClause s : obj.getChanges()) { if(s.getSymbol().getMetadataObject().getNameInSource()!=null){ columnName=s.getSymbol().getMetadataObject().getNameInSource(); }else{ columnName=s.getSymbol().getMetadataObject().getName(); } changes.add(new UpdateSet(columnName, getStringValue(s.getValue()))); } translateWhere(obj.getWhere()); }
Expression expr = clause.getValue(); Object value = resolveExpressionValue(colName, expr);