It is currently 5 August 2020, 11:05 Advanced search

How to change tables without impacting existing code?

Questions and answers on how to best use Instant Developer

How to change tables without impacting existing code?

Postby john w » 25 October 2019, 13:14

Every year I have to change datatables to reflect that year's data. For example, I have table CostFactor2019 and now need to use a table CostFactor2020. (We get the data from a 3rd party so it is the way we access it.)

If I import the CostFactor2020 table, and change my code to use it,(such as Select statements, etc.) I find that when I delete the CostFactor2019 tables all the code and calculations are trashed. I guess they lose reference. My guess is all the objects are still somehow tied to a table that now longer exists. If I don't delete it is not working with the correct data. I have tried renaming the tables in InDe but that presents a problem because the code reference is the data table name. In my scenario the Code would still point to CostFactor2020 even though I renamed the table in InDe to CostFactor2019.

Is there a simple way to make the table change without having to code the app over again?

If I have confused you I apologize.
Regards

John W
User avatar
john w
 
Posts: 609
Joined: 24 October 2012, 16:29
Location: Apple Valley, Minnesota USA

Re: How to change tables without impacting existing code?

Postby d.termini » 25 October 2019, 13:40

Does the table structure change between years?
If not you may just add a "year" column and append the new data, then you might delete the old records later.
If the structure changes too, you may try to replace the references to the table with drag&drop the new table over the old one keeping Alt pressed.
d.termini
 
Posts: 813
Joined: 13 November 2017, 8:41

Re: How to change tables without impacting existing code?

Postby john w » 25 October 2019, 13:58

d.termini

Thanks for the suggestions. I will explore the drag and drop first. Try what sounds easy first and hope it works.
Regards

John W
User avatar
john w
 
Posts: 609
Joined: 24 October 2012, 16:29
Location: Apple Valley, Minnesota USA

Re: How to change tables without impacting existing code?

Postby john w » 25 October 2019, 14:47

Sadly the drag and drop does not seem to resolve my issue. After I do the drag and drop then delete the old table I lose all kinds of things in my formulas.

I will look at adding a year to the table and then adding the year to the where statement.

Hmmmm...it still seems this should not be necessary but what do I know.
Regards

John W
User avatar
john w
 
Posts: 609
Joined: 24 October 2012, 16:29
Location: Apple Valley, Minnesota USA

Re: How to change tables without impacting existing code?

Postby ljwilson » 25 October 2019, 15:43

John,

You are starting a little earlier this year on this issue :-)

Isn't this the same issue we discussed this last year?
Odd behavior - declared variables.


http://forum.instantdeveloper.com/viewtopic.php?f=7&t=85395

...jack
ljwilson
 
Posts: 528
Joined: 26 November 2013, 14:15

Re: How to change tables without impacting existing code?

Postby john w » 25 October 2019, 17:05

Jack

It is the same issue. I have not been able to get any of my workarounds to resolve it. I have opted for adding a year field to my data tables, I created a global variable to hold the year then added it to my Where statements. So it DataYear = gvDataYear.

I am thinking this may be a better solution in the long term. Then I can just clean up the data on the database side and leave the app alone apart from setting the gvDataYear every year.

At least that is the plan.
Regards

John W
User avatar
john w
 
Posts: 609
Joined: 24 October 2012, 16:29
Location: Apple Valley, Minnesota USA


Return to Tips & Tricks

Who is online

Users browsing this forum: No registered users and 1 guest