Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Question about views
Message
De
28/04/2006 22:56:21
 
 
À
28/04/2006 18:49:55
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 6 SP5
Divers
Thread ID:
01117697
Message ID:
01117748
Vues:
21
>>Hi Hilmar
>>
>>Simply call the UDF that assigns the primary key from the View's Default, not the table, you will need to make the Primary Key field updateable.
>
I think Bruce was right, Set the default value of the Primary Key field in the View to the same UDF as the table, that UDF of course is stored in the DB , and make the PK Field updatable. The default value is just that, a default value, if the view already assigns a value to the PK Field, the Default Value rule of the database will not trigger then.

>I agree with Craig here, that that should not be placed in the view. Two practical problems arise; first, in principle I might open the table directly in one place, and through a view in another place.
>

No Problem, if you open the table directly, the UDF call stored in the default value for the PK Field of the table is triggered. If you open table thru View, the same UDF call will be made, this time from the View. Try it, I did.

>Second, I was hoping to continue using the view designer, and I don't see how to assign a default value to a field in the view designer.
>

Never used the VFP6 view designer, don't you have the Properties button in the Fields tab? But you can edit the sql code of the view, right? Right-Click, View SQL, just add the required statement in there, i.e.:

DBSetProp(ThisView+".pk_guid","Field","DefaultValue","newguid()")

>The problem might be circumvented by assigning the value in the forms. That, I consider quite old-fashioned; from basic design principles, I had rather let the database assign the PK value. This might done in an emergency, though.
>

Agree, doing that in the form its a no-no.

Final thought: after all, the View is a piece of the database, just as the table is, so in the end, the database will be assigning the PK, and your PK-assigning code is in just one place, in the DB. It just gets called from 2 diferent places of the DB, the Table, or the View
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform