PDA

View Full Version : Compare Two Databases for structural differences


ABC123

Jim Chapman
12-02-2004, 06:28 PM
Hello,

When developing for an application is use it is helpful to be able to check the structure of your production (in use) database against your development database to make sure the structures exist in the development database before you implement changes.

The attached utility script does this. I have done limited testing in both verions 5 and 6, and it appears to work.

Let me know your thoughts,
Jim

CALocklin
12-03-2004, 05:10 AM
Gee, why didn't I think of that!?

Jim, this is really great! It will save me a lot of time and make my updates more accurate. It will definitely be added to the "developer utilities" button on my control panel toolbar. Thanks. Where do I send my check?

I modified the initial dialog box a bit as shown below and in the attachment. Basically, I moved the "both apps must be selected" routine into the dialog itself, along with a warning message, so the user won't have to start over. I also tweaked the appearance, changed the title from "Compare Tables" to "Compare Applications", and added my own personal preference to the OK / Cancel buttons. To simplify the buttons and scripting, I changed them to simply "15OK> and "15Cancel> since that's all that is really needed for simple buttons. I also removed the {region} that's around them, which reduces the size of the area below the line, and added a small space above them so they are centered better vertically. I often don't bother adding that little extra vertical space but in this case I thought it looked noticeably better.

Also note that I did put a blank space before each of the input boxes and before the OK button. This is strictly to indent them for appearance purposes.

I also ran it through my Script Formatter before posting it and the options are currently set up to add spaces wherever possible so you will see a few extra spaces in the code. I do this so I can use the 'new' Ctrl-LeftArrow and Ctrl-RightArrow capability for navigating the scripts. The Formatter also added the highlighting around the label and the single quote after the END statement so I can search for END' and not find every END IF, END SELECT, etc. For anyone interested, the Script Formatter is available for free on my website - the only charge is that you are required to tell me you are using it.

Finally, just another 'plug' for keyboard macros - the bold was added to the subtitles with one keystroke each. By adding this to my keyboard macro program, adding bold to dialogs to make them more readable is now very quick and easy. So far, I haven't confirmed that anyone else in Alpha land is using a keyboard macro but if you are typing a lot of xbasic and not using a keyboard macro you are wasting a LOT of time. I guess that's ok if you want to charge someone for the extra time but, personally, I'd rather make things easier on myself.

Cal Locklin
www.aimsdc.net


To add this code section to the routine, just replace everything from the first DIM statement to the "Create Text List...." header section.

DIM SHARED vDevelopmentDB as C
DIM SHARED vProductionDB as C
DIM SHARED varC_result as C
'---------------
TryAgain:
'---------------
varC_result = ui_dlg_box( "Compare Applications",
{ysize=.3}{sp};
{font=MS Sans Serif,8,b}Select Development Database:{font=MS Sans Serif,8,n};
[%fTables(*.adb)%.80vDevelopmentDB] ;{sp};
{font=MS Sans Serif,8,b}Select Production Database:{font=MS Sans Serif,8,n};
[%fTables(*.adb)%.80vProductionDB];{sp};
{line=1,0};{sp};

%dlg%,
IF a_dlg_button = "OK"
IF vDevelopmentDB = "" .or. vProductionDB = ""
ui_msg_box( "DATABASE MISSING", "Please enter both databases or press the Cancel button.", 48 )
a_dlg_button = ""
END IF
END IF
%code%)
'********************************************************
'****** Check to make sure user pressed the 'OK' button and that both DB's have been selected
IF varC_result "OK"
END'
END IF

ronwills
12-03-2004, 05:19 AM
I keep getting the following Alpha Five error:

Script:Compare Databases line:60
vArrayDevList[i].table=substr(vArrayDevList[i].path,at(chr(92),vArrayDevList[

vArrayDevList[]not found

I attempted to run this script in the Development Database and after getting the error message, created a new database and ran the script from it. Either way I received the same error. Any ideas what may be causing this?

Ron Wills

CALocklin
12-03-2004, 05:35 AM
This sounds silly but are you sure there are tables in your application?

CALocklin
12-03-2004, 05:41 AM
I couldn't leave it alone. Here's another update that adds buttons for entering the current database name. Unfortunately, adding the buttons moves the header up away from the input box but I think most people will be able to live with this. I tweaked it a bit but that was the best I could get.

It exactly replaces my previous script so it also replaces everything from the first DIM statement to the "Create Text List...." header section.

Cal Locklin
www.aimsdc.net

DIM SHARED vDevelopmentDB as C
DIM SHARED vProductionDB as C
DIM SHARED varC_result as C
DIM dlg_result as C
varC_result = ui_dlg_box( "Compare Applications",
{ysize=.3}{sp};
{region}
{sp};
{font=MS Sans Serif,8,b}Select Development Database:{font=MS Sans Serif,8,n}{endregion} {region}{endregion};
[%fTables(*.adb)%.80vDevelopmentDB] ;{sp};{sp};
{region}
{sp};
{font=MS Sans Serif,8,b}Select Production Database:{font=MS Sans Serif,8,n}{endregion} {region}{endregion};
[%fTables(*.adb)%.80vProductionDB];{sp};
{line=1,0};{sp};

%dlg%,
IF a_dlg_button = "OK"
IF vDevelopmentDB = "" .or. vProductionDB = ""
ui_msg_box( "DATABASE MISSING", "Please enter both databases or press the Cancel button.", 48 )
a_dlg_button = ""
END IF
END IF
IF a_dlg_button = "cur1"
vDevelopmentDB = a5.Get_Name()
IF vProductionDB = a5.Get_Name()
vProductionDB = ""
END IF
a_dlg_button = ""
END IF
IF a_dlg_button = "cur2"
vProductionDB = a5.Get_Name()
IF vDevelopmentDB = a5.Get_Name()
vDevelopmentDB = ""
END IF
a_dlg_button = ""
END IF
%code%)
'********************************************************
'****** Check to make sure user pressed the 'OK' button and that both DB's have been selected
IF varC_result "OK"
END'
END IF

Barry Potter
12-03-2004, 07:40 AM
Jim
It's brilliant especially when updating an old DOS app done in
A4 to A5
Thankyou
Barry

Jim Chapman
12-03-2004, 07:18 PM
Hello Ron,

""vArrayDevList[i].table=substr(vArrayDevList[i].path,at(chr(92),vArrayDevList[""

I had one other version 5 user who reported this same thing. But upon rebooting his computer it has run OK since. I'm pushing my understand of how Alpha deals with arrrays by my dim'ing of a second subelement, after it has been created by the vArrayDevList.initialize_properties() statement. This issue can be coded around fairly simply.

Want version and build of A5 are you using?

Thanks,
Jim

Jim Chapman
12-03-2004, 07:20 PM
Thanks for the kind words Cal.

""Where do I send my check? ""
If you sent one to me, I'd have to send two to you:-)

I appreciate all you have given to the Alpha community.

Thanks,
Jim

Jim Chapman
12-03-2004, 07:22 PM
Thanks Barry,

I appreciate it.

Jim

CALocklin
12-03-2004, 07:52 PM
By the way, for those who didn't catch the reference, the "Gee, why didn't I think of that!?" was a quote from Jim's newsletter article.

martinwcole
12-07-2004, 08:50 PM
Jim and Cal, I added(replaced) Cal's script in yours, and I am getting that same error message reported by the other user, but rebooting did not help - included is a picture of the dialog I am using:

vArrayDevList[i].table=substr(vArrayDevList[i].path,at(chr(92),vArrayDevList[

vArrayDevList[]not found

CALocklin
12-09-2004, 07:38 AM
This is interesting. It's working fine for me in v6 but causes that same error in v5.

The only insight I've come up with so far is that the Load_adb_def() command doesn't seem to return a crlf string in version 5. It looks like it in the interactive editor but a check for chr(10) or chr(13) turns up nothing. In v6, it's definitely a crlf sting. The issue with this is that the .initialize() command seems to need a crlf string.

I don't have time to dig any further right now but I will when I get a chance.

Cal Locklin
www.aimsdc.net

Jim Chapman
12-14-2004, 08:31 PM
It appears that version 5 and the first script have issues. Although the origional script appears to work fine in A5v6, several A5v5 users reported that they have problems running the script. Cal Locklin was very quick to identify what I believe is the source of the problem, the load_adb_def()function. My thanks to Cal for his insight, and to Martin Cole and his fantastic new computer that was especially adept at choking on this script. When I finally got a version to run on Martin's computer, I breathed a sigh of relief.

Attached is a modified script that I believe will work well with A5v6.

Any feedback on this?

Thanks,
Jim

Steve Bovino
08-04-2005, 08:06 AM
Jim:

Great utility except I have come accross a problem. I have attached the error message. My development db is on my pc and the actual db is on a lan server. When I run the compare the error message seems to indicate that the pathis not being translated correctly. There should not be a C:\ in front of the path. I have tried mapping the production directory and the result from the program is the same. Thanks for any insight.

Steve

Steve Bovino
09-18-2005, 03:30 AM
Once I mapped the location of one of the databases to a logical drive Letter letter as opposed to a share name it all worked.

Mike Thomson
09-29-2005, 05:52 AM
A useful utility, thanks Jim

What would be really nice is to have a program which maps your production database, and maps all the field and index layouts. Then when you distribute the program you have a function which reads this map file and applies and data file change (field, indexes, new tables) etc as required as part of an upgrade.

I have thought of developing this to put on Alphabay - Alothough I would like someone else to do it. It would really make job of deployin upgrades much easier.

Mike

rbsystemsdesign
05-20-2009, 04:43 PM
Bill Parker (of A5Doc) pointed me to this routine and I downloaded the latest version from Jim Chapman. I get an error in line 153 translating the path in A5v8 - screen dump attached. My drive G is native, not a network disk and is not shared as in Steve Bovino's posts.

Any thoughts?

Roland

Stan Mathews
05-20-2009, 05:21 PM
I don't think Alpha and/or the coding likes an ampersand in the path. Can you rename that directory?


Edit: Well, I just tested someithing I think is similar and it seemed to work. May be internal to the routine.

rbsystemsdesign
05-20-2009, 05:44 PM
Thanks for the thought. A5 has been working perfectly happily with the ampersand in the path for the last 18 months - it's just this routine that doesn't translate the path correctly.

It's noticeable that the "g:" is missing in the errors line:-

"Error loading g:\rbsd\clients...."

"...cannot find the path specified. \rbsd\clients...."

i.e. the drive letter isn't being parsed.

I'll try it in V9 on my machine but the client is using v8 and isn't likely to upgrade.

rbsystemsdesign
05-20-2009, 06:56 PM
Problem solved. I had imported the two copies of the database from the client's site and put them into new folders on my pc. The drive and folder names didn't match those on-site and I ran the utility in a new database without having previously opened the two imported databases.

It seems A5 rebuilds the pathnames internally when you open a copied database. As I hadn't opened them first the utility was trying to find the original paths which weren't available to it on my machine.