# Making a copy of a foundset to keep in memory

**URL:** <https://forum.servoy.com/t/making-a-copy-of-a-foundset-to-keep-in-memory/9896>\
**Category:** Classic Servoy\
**Created:** [November 19, 2008, 3:56pm UTC](https://forum.servoy.com/t/making-a-copy-of-a-foundset-to-keep-in-memory/9896 "2008-11-19T15:56:33Z")\
**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:** [November 19, 2008, 3:56pm UTC](https://forum.servoy.com/t/making-a-copy-of-a-foundset-to-keep-in-memory/9896/1 "2008-11-19T15:56:33Z")

</div>

I want to make a copy of my foundset and put it into an (object)variable.

The use of this functionality is, that I want to keep an exact copy of the foundset in memory without having to do a requery on my database.  
That is why I don’t use the databaseManager.getSQL(foundset) and databaseManager.getSQLParameters(foundset) functions.

```auto
  var _foundset = forms[_form].foundset;
	var _progobj = globals.nav.program[_program]; // This is an Object
	
	_progobj.related_foundset = _foundset.duplicateFoundSet()
	_progobj.related_foundset.unrelate();

```

So I make a duplicate of the foundset and I put this in an objectvariable .  
Extra I do also a call to unrelate()

But what I see that when the original foundset is changed, that the foundset in the objectvariable is changed also.  
That is not what I want. I want the objectvariable to keep the original foundset

This is Servoy 3.5.7.

Is there a way to achive this?

Martin

---

<div class="post-metadata">

**Author:** ![IT2Be](https://avatars.discourse-cdn.com/v4/letter/i/dc4da7/32.png) [@IT2Be](https://forum.servoy.com/u/IT2Be)\
**Post date:** [November 19, 2008, 6:44pm UTC](https://forum.servoy.com/t/making-a-copy-of-a-foundset-to-keep-in-memory/9896/2 "2008-11-19T18:44:40Z")

</div>

Your duplicate is not a real duplicate but a reference to the original.

For what you want you would have to clone the foundset (not possible ‘out of the box’ as far as I know).

But why don’t you use dataset? That is static…

---

<div class="post-metadata">

**Author:** ![jcompagner](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/jcompagner/32/4889_2.png) [@jcompagner](https://forum.servoy.com/u/jcompagner)\
**Post date:** [January 7, 2009, 11:37am UTC](https://forum.servoy.com/t/making-a-copy-of-a-foundset-to-keep-in-memory/9896/3 "2009-01-07T11:37:40Z")

</div>

duplicate is a clone with exactly the same initial state as the original but if you then change the original (do a new query)  
the duplicate shouldnt change (also have that new query)

So what do you mean with changed? what is changed in the original foundset? A record? That will be shown in the duplicate also ofcourse.
