Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Thought process
Message
De
15/02/2018 15:47:09
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Database:
MS SQL Server
Divers
Thread ID:
01658136
Message ID:
01658151
Vues:
42
>>Hi everybody,
>>
>>I need a bit of help to figure out how to change my old application.
>>
>>I have a few questions.
>>
>>First problem is, as always, trying to figure out a good name for a property. We changed our database structure. I want this application to work with both databases (old and new), so first I need a property that will tell me what kind of DB it is. Here is my current code
>>
>>if '[4.6.50' $  oAppObj.DbVersion
>
>
>If you handle only two database versions old and new then change the name to DbVersionNew-> .t. when you should handle new version :-)

I think the above is too simplistic for larger systems. If possible I use a factory to instantiate "fitting" action objects with the correct code for the version identified via version string - makes for much cleaner code. Sometimes only lists / names in a config object are needed, but IMO such versioning eliminates quite a bit of cruft in code needing to work perhaps with versions a few releases back (as not everybody updates in large orgs without strict control)
>
>
>>
>>I think having some boolean property will be better than repeat this condition in various methods - but I am stuck on naming the property :(
>>
>>The second problem is much more complex.
>>
>>In the original DB structure we stored address and email and phone information directly in the table (say, guests, accounts, vendors, etc.)
>>
>>In the new DB we switched to use Contacts table (Addresses, Emails, PhoneNumbers + linking tables).
>>
>>It presents me now with the problem for that particular application which is called import. The idea is to have an Excel file with information populated and the way I processed it was opening SQL tables into local dbfs, making them updateable and then insert data, etc.
>>
>>Say, this is how my vendors table was originally populated:
>>
>>
>>insert into i_vendor (full_name, Contact, address, address2, ;
>>		City, State, Zip, E_mail,  area_code, Phone, ;
>>		check_bx1, check_bx2, check_bx3, check_bx4, check_bx5, ;
>>		number_1, number_2, number_3, number_4, number_5, ;
>>		text_1, text_2, text_3, text_4, text_5, ;
>>		date_1, datetime_1, memo_1, operator, salespoint, date_time, ExternalID) ;
>>		values (csrVendors.full_name, csrVendors.Contact, csrVendors.address, csrVendors.address2, ;
>>		csrVendors.City, csrVendors.State, csrVendors.Zip, csrVendors.Email, csrVendors.area_code, csrVendors.Phone, ;
>>		inlist(proper(csrVendors.check_bx1),'Yes','1','True','T'), ;
>>		inlist(proper(csrVendors.check_bx2),'Yes','1','True','T'), ;
>>		inlist(proper(csrVendors.check_bx3),'Yes','1','True','T'), ;
>>		inlist(proper(csrVendors.check_bx4),'Yes','1','True','T'), ;
>>		inlist(proper(csrVendors.check_bx5),'Yes','1','True','T'), ;
>>		csrVendors.number_1, csrVendors.number_2, csrVendors.number_3, csrVendors.number_4, csrVendors.number_5, ;
>>		csrVendors.text_1, csrVendors.text_2, csrVendors.text_3, csrVendors.text_4, csrVendors.text_5, ;
>>		csrVendors.date_1, csrVendors.datetime_1, csrVendors.memo_1, oAppObj.OpCode, ;
>>		oAppObj.salespoint, datetime(), csrVendors.ExternalID)
>>
>>	thisform.nInserted = thisform.nInserted + 1
>>
>>Now I need to insert into multiple tables, but how would I get the autoincremented Ids without actually saving the info first? Should I probably generate SQL script here instead?
>>
>>Appreciate some helpful ideas in advance.
>
>
>Do the whole insertions in transaction and use GETAUTOINCVALUE().
>
>If it is SQL Server then prepare the whole script using parameters and use SCOPE_IDENTITY()
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform