Move entity from module to other one

Move entity from module to other one

Hi There,

I have a module with a few entitys with a lot of data that I want to move to a core module. How can I do this and keep the values in the entitys. I dont want to create empty entitys in the new module.

Personal cloud running on OS9.

Hi freek,

On Personal cloud... hum... you cannot move (without losing data), but you can create copies.
One way to do that is to reference those entities in the new module and create an advanced query with some simple sql like
SELECT * FROM table1
Hi Tiago,

When trying to do this I get the following error:

Database returned the following error: Error in advanced query SQL1: An explicit value for the identity column in table 'IPNV9R003.XXXXX' can only be specified when a column list is used and IDENTY_INSERT is on

It had been a while since I made something like that in OutSystems... You actually have to specify attributes and leave the Id attribute out.
Like this:

( {Table2}.[Att2] ,{Table2}.[Att3] ,{Table2}.[Att4] ,{Table2}.[Att5] )
SELECT {Table1}.[Att2] ,{Table1}.[Att3] ,{Table1}.[Att4] ,{Table1}.[Att5]
FROM {Table1}

So, as you see, depending on the amount of attibutes and tables it can get annoying... :)
Hi Tiago,

You will understand that this is a bad solution that will not working because there are other entitys depending on the Id. I will do a query on the old table add a extra Id (int) field on the new table import there the old id and use that to import the other entitys.
The problem is on the Personal Environment.
You could make SET IDENTITY_INSERT {Table2} ON and then back to OFF but this doesn't work on Personal Environment... And the order of the tables would also matter.
If you can make it work on Personal Environment - user permissions I think - you could use the Id attribute and add IDENTITY_INSERT like this:

( {Table2}.[Id] ,{Table2}.[Att2] ,{Table2}.[Att3] ,{Table2}.[Att4] ,{Table2}.[Att5] )
SELECT {Table1}.[Id] ,{Table1}.[Att2] ,{Table1}.[Att3] ,{Table1}.[Att4] ,{Table1}.[Att5]
FROM {Table1}
In addition to that, you may create a custom export/import of course, but that's a bit more work.
Why don't you try doing the reverse?

Move the stuff you dont want to another module? Would that work for you?

It goes like this:
  1. Clone the core module
  2. Rename original module
  3. Rename cloned module
  4. In the core module remove what you do not need
  5. In the cloned module Reference the entities from the original module
  6. In the cloned module Find and replace the entities to point to the original one
  7. In the cloned module remove the entities
Hi Rui,

Because I want to combine a few esapces this will not help.

SET IDENTITY_INSERT {Table2} ON is possible because I do not have the permissions.

You need to do one of two things:

1. As others have stated, use the SET IDENTITY_INSERT to make this work. You have said you do not have the permissions to do this... so you can't.

2. Write a ton of code that goes through your data, inserts the values that everything else depends on into your new data model, retains the ID in a temporary mapping system... then inserts the next "level" of data, pulling from the old entities, using the mapping system to replace the IDs with the new IDs for the FK rows, and then inserting the row... over and over again...

Expect to spend a lot of time on this, test, etc.

As Rui suggested, your much better option is to leave the data in-place, and take everything else out and move it to another module.

The only time it ever makes sense to go through this painful data move is if you are merging data models from two separate eSpaces. I did this once before on a large scale and it was pretty miserable. Took about 120 man hours for a few dozen entities in three or four eSpaces to merge them into one.

I have created an UserExtensionModule to assign a manager to each exsisting User in "User/Roles" of my environment. I have referenced the UserExtended entity to the coreModule. But still there exists some problem in the matching of primarykey. How would we get the primary key of that particular user. Where i exactly want to use the manager is, if a user sends request it should be automatically intimated to the manager through mail. if i use "GetUserExtended(RequestTable.current.UserId).User.Manager", It shows "Key 0 not found". Please help me to fix this.

Hi Vinodhini,

You replied to a months-old post, with a question that is not related. Please don't do that, but create a new topic for it. Thanks!
Sorry kilian. Thanks for your note.