72
Views
6
Comments
External Database Integration
Application Type
Traditional Web, Mobile, Reactive

Hello Team,

I made the mistake of forgetting to alter one of the columns' data types during the external database integration. The user also requested that the table's name be changed. Almost six months have passed, and the data is finally in the table. We don't want the table's data to be lost.
Is it possible for us to modify the table's name and the column's data type? 

If I change the name of the table, the physical table name remains the same, & in the advanced query, I did not get the data as the name has changed. 

Please provide the best option so that I don't lose the data and can get the desired outcome. 

UserImage.jpg
Nani

You can not change the physical table name, outsystem wont allow you because it is common name in all environments, so you can't change the physical table name.

If you want different physical table name , there is only one option creating a new table.

You can change the column data type, but it depends on previous data type and there are limitations due to data.


Create a new table with a proper table name you required.
Example if table name is "Employee" then Physical table name will be "OSUSR_cbg_Employee" and create a same attribute in old table and data you are getting from external databse, so you are changing table name in outsystem integration studio and also change columns data type(Note: there are limitations).

2020-11-25 10-45-32
Mostafa Othman
Champion

Hello Pradip,

Can you please confirm if you want to change table name into external database or in OutSystems logical name only?

Regarding changing data type of column you can change it but also based on number of records existing in table as if its million of records this change may take long time and may also fail.

As its production environment so first of all its better to backup your table first before doing any changes then in case lose of any data you can insert data again from backup table to original table.

2023-02-26 23-17-33
Kshitij Raheja

Hey @Pradip Chavhan 

Please let me know which external database you are using, depending on that there will be multiple ways to do it 

1) Create new table - example - create table NewTable as select * from OldTable

2) if you are using Oracle you can use Rename Table https://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqljrenametablestatement.html

After renaming or creating new table you have to reintegrate it and have to reconnect it to your modules all again

To Change column datatype you have to make sure that new datatype can hold all the data 
example integer cant hold text data

ALTER TABLE NewTable MODIFY COLUMN OldColumn Datatype;

Create new column with the new datatye then run the Update query like
ALTER TABLE NewTable ADD NewColumn Datatype;
Update NewTable set NewColumn = OldColumn;

also, check out this StackOverflow question for a similar query
sql server - Change type of a column with numbers from varchar to int - Stack Overflow 


2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

Hi Pradip,

As you already have the external database in production and connected to your OutSystems application, it is upmost important to have a good plan, or else you end up with a high possibility that your application is not working as expected for a longer period than necessary.

Simple approach, with significant downtime

  1. You don't necessarily rename your external database table, no user will or OutSystems developer sees it directly. You can rename the entity name in your outsystems database extension, the refactoring of that in your application should be smooth.
  2. To change the data type it is important to understand, that when you change your database table column data type in the external database, your OutSystems application is no longer compatible. You need to update the database extension, publish the it, then change all consuming modules, maybe so refactoring is required because of the changed data type. Then you need to test that and bring it to production. All that time your app can not work correctly. If this downtime is not possible, I suggest an alternative approach with zero downtime.

Alternative approach, with zero-downtime

  1. Create a new column in the external database table
  2. Update the OutSystems database extension and publish it
  3. Update your app to not only fill the old attribute but also the new attribute
  4. Write a timer that copy/paste the old attribute value for existing records into the new attribute, preferable via advanced SQL. Alternatively you could also do this on using a database management tool directly on the external database.
  5. Publish, test and deploy this to production.
  6. Now change your OutSystems app and the OutSystems database extension, to remove the references to the old attribute, and only use the new attribute value.
  7. Publish, test and deploy this to production.
  8. After all runs smooth in production you can removed the old attribute from the external database table.]

Regards,

Daniel

2022-05-18 07-58-50
Pradip Chavhan

SQL Server is the external database that I'm using. In any case, I must update the extension to make this adjustment.
Since the column currently only contains the values 1 and 0, I am not concerned about changing the data type of the column.

In outsystems data model, we have 1 table/entity with the name A. On the other side of the physical table, we have tables A & A1. And the actual data is in Table A1 but aggregates point to Table A.

How do I resolve this issue? 

Can we make a change to the below entity? 

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

You can read and update the entity as any other entity. But be careful with changing OutSystems meta data entity records. Make sure you can revert your changes if they don't give that desires outcome.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.