So, I build most of my applications without much planning and preparation. Yeah, yeah, I know P*** poor planning = P*** poor performance, but I am not a professional and I don’t pretend to be, I just quickly knock systems together for a hobby, as a learning process and also for demo purposes.
In the the following case, I had a table called MP_OPPORTUNITIES, named thus for historical reasons and so that I could easily copy and paste code from another application into this one. However, the application that I am working on ‘might’ make it into OpenInsight 10, or I might release it on a case by case basis to OI WORKS developers, I’ve not decided yet, and for that reason I’d like to have table names and form names that make some sense.
Anyway, the form would be better named MP_ORDER_ENTRY and therefore the corresponding data table would also benefit from being called MP_ORDERS (following my naming convention). So, I dropped into the Database Manager, changed the table name and was prompted with the Impact Analysis report. I noted the items and duly renamed the table.
Problem 1 – The form now opens as read only and I cannot change the data bindings, as I had expected I would :(.
Plan B: Restore from backup and this time I’ll clear out all of the data bindings in the form, save it and then rename the table.
Problem 2 – OI will now not save the form because I appear to have a rogue data binding and OI cannot find column ” “. I checked all of the data bindings and even removed a couple of edit tables, alas no joy!!
A quick call to support and once again the guys put me on the right track.
It is always easier to do things the right way, instead of blindly ploughing into self made problems.
So, if you have a badly named table, this is the best way that ‘I’ have found to put your system right:
- Design the database and system properly from the outset ;-).
This should be a given, but if you are like me, you’ll need to do the following:
- Firstly take a good backup of your system, right before you try this and not the day before, like me (will I ever learn?).
- Open the Database Manager, select the table that you wish to rename and rename it to your new table name.
- When you rename the table, OpenInsight will conveniently run an Impact Analysis check on the system and report entities that you might (will) need to look at following the renaming of the table. OpenInsight does not (at this stage in the OpenInsight 10 development) rename all of the values throughout the system for you. That’s currently a manual process.
In my case, this means looking at two forms. For a system that might be a little older, it gets a little more difficult and you might have popups, reports and other entities to consider. It might even be worth sticking with your badly named table. After all, the only time that end users are likely to see the table name is if you have exposed any report writing tools to your users.
I should also point out that, I have previously chosen bad table names and I have renamed them before creating any forms, popups, reports, etc. against the data tables. Those rename perfectly and with no extra worries or work involved.
- So, we now have our renamed table and list of problem forms. Lets sort those out by opening a record (Ctrl+R, or Open Record), selecting SYSREPOSWINS as the Table Name and locating our required Record/s. In my case it is the form called SYPHERSPOS**MP_OPPORTUNITY_ENTRY (as shown below).
- This will open up the record in the OpenInsight Integrated Development Environment (IDE) using the appropriate tool, the System Editor ++ in this instance. For the uninitiated (like me), this is a daunting screen and one in which (I think) someone with only a little knowledge can do a lot of damage – so be careful and get advice if you don’t know what you are doing.
- Thankfully, OpenInsight’s ‘Find and Replace’ feature comes to the rescue. From the Search menu, we select Replace and we are prompted with the dialogue window shown below. Simply enter the value that we want to search for in the ‘Find what’ prompt (our old table name in this instance) and the new new table name in the ‘Replace with’ prompt. All very straight forward.
OpenInsight will then trawl through the record and let you know how many instances of the value have been found. Click Replace All (as above) and the System Editor makes the changes and reports the replacements accordingly.
- So, we now have a renamed table and a form with an old name and new data bindings. We can now launch and run the form and it’ll work just fine, pulling data from the newly named table. However, one last step is needed to put our system right.
We open the MP_OPPORTUNITY_ENTRY form in the Forms Designer and simply select ‘Save As’ from the File menu and save the form with the new name – MP_ORDERS.
This will leave you with both our new MP_ORDERS form and the old MP_OPPORTUNITIES form. Open the old form and select Delete from the File menu and you are done.
Of course, all of this hard work could have been avoided if I’d spent a few minutes properly planning my system. However, it is nice to know that OpenInsight and the guys at Revelation Software still have my back and if I get myself into, they can help me to get out of that mess again.
Note to self – It really is time to get some proper training 😉
Thank you to Andrew and Bob for helping through this.