Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changing Data Table Location of a View
Message
De
20/10/1998 15:09:37
 
 
À
18/10/1998 01:54:26
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00147871
Message ID:
00148602
Vues:
21
>>I am using a view in a form: v_test
>>The view is a local view in a dbc called: test
>>The table is called test.dbf and is in a folder called c:\test\01
>>
>>So the SQL for the view is:
>> SELECT * FROM test!test
>>
>>I want to be able to use the same view against the same table located in folder c:\test\02. In other words, multiple sets of data.
>>
>>The cursorsource of the DE is v_test.
>>
>>How do I change the table location in the DBC to be:
>> c:\test\02 instead of c:\test\01
>>
>>Any ideas?

I'm using a different approach, I'm not proud of it, and didn't want to do it this way, but the powers that be wanted a bunch of little separate files (batches), and this approach seems to be working.

1. Create your view using the view designer.
2. Use Gendbc.prg to create a programmitic version of the view.
3. Go to the select statement in the genearated program and modify it per this example:
Change
SELECT * FROM mydbc!Detail WHERE ClmID = ?lcClmID
to
SELECT * FROM ('mydbc!'+lcDetailTable) WHERE ClmID = ?lcClmID

4. Run the modified program to create your view.

Then, whenever I USE the View, I add the following code for every updateable field. Actually I cut the DBSetProgs out of the gendbc generated PRG file and make the same change I made to the select statement above. If the view is in a dataenvironment, I guess this code would go into the cursor init, but I'm not sure about that.

DBSetProp('V_VIEW.ClmID', 'Field', 'UpdateName', lcDetailTable+'.ClmID')
Do this for all DbsetProps that reference the table.

The main advantage is you don't have multiple copies of the view to keep track of.

The disadvantage is that this is really a bit of a "cheat", you need to have the lcDetailTable variable defined, and even then the view acts strangely when you open it from the command window. Seems to work fine when opened under program control though.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform