# FoundSetUpdater: set columnX = columnY

**URL:** <https://forum.servoy.com/t/foundsetupdater-set-columnx-columny/14828>\
**Category:** Classic Servoy\
**Created:** [October 7, 2011, 10:33am UTC](https://forum.servoy.com/t/foundsetupdater-set-columnx-columny/14828 "2011-10-07T10:33:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [October 7, 2011, 10:33am UTC](https://forum.servoy.com/t/foundsetupdater-set-columnx-columny/14828/1 "2011-10-07T10:33:27Z")

</div>

With the foundset updater, you can set some value into a column and then this will generate a SQL script like this:

```auto
UPDATE table
SET columnX = 1
WHERE <condition>

```

The decided by Servoy based on the foundset. This works well.

But in the same way I would like to fill my column with a value of another column, so like this:

```auto
UPDATE table
SET columnX = columnY
WHERE <condition>

```

I don’t see why this should be a big problem for Servoy, but the updater doesn’t accept it, when I use:

```auto
_updater = databaseManager.getFoundSetUpdater(foundset)
_updater.setColumn('columnX, 'columnY')
_updater.performUpdate()

```

then Servoy fails because columnX is a numeric type.

Could this be a functionality for a next version of Servoy?

---

<div class="post-metadata">

**Author:** ![rgansevles](https://avatars.discourse-cdn.com/v4/letter/r/3d9bf3/32.png) [@rgansevles](https://forum.servoy.com/u/rgansevles)\
**Post date:** [October 10, 2011, 7:32am UTC](https://forum.servoy.com/t/foundsetupdater-set-columnx-columny/14828/2 "2011-10-10T07:32:03Z")

</div>

Martin,

You can use the third option described in the foundsetUpdater docs: [http://wiki.servoy.com/display/public/D … SetUpdater](http://wiki.servoy.com/display/public/DOCS/JSFoundSetUpdater)

Loop through the updater simultaneously with the foundset and assign the column value.

Rob

---

<div class="post-metadata">

**Author:** ![martinh](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@martinh](https://forum.servoy.com/u/martinh)\
**Post date:** [October 10, 2011, 7:43am UTC](https://forum.servoy.com/t/foundsetupdater-set-columnx-columny/14828/3 "2011-10-10T07:43:48Z")

</div>

> rgansevles:  
> Martin,
> 
> You can use the third option described in the foundsetUpdater docs: [http://wiki.servoy.com/display/public/D … SetUpdater](http://wiki.servoy.com/display/public/DOCS/JSFoundSetUpdater)
> 
> Loop through the updater simultaneously with the foundset and assign the column value.
> 
> Rob

Rob,

For this option I don’t need an updater.  
I can loop thru the foundset as well without an updater.

I just wanted with 1 single SQL-statement to do this update without loop and without using rawSQL.

Maybe adding a new method to the updater in the next version?

```auto
setColumnXToColumnY(nameX, nameY)

```

It would be even more perfect if the nameY can also be a related field, for example:

**setColumnXToColumnY(‘columnX’, ‘tableX\_to\_tableZ.columnZ’)**

with the only condition that the relation ‘tableX\_to\_tableZ’ was already used in the original foundset.  
Since you already have the query including the joins, I don’t think this will be too hard to implement.  
But it will improve the performance.

Martin
