Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Views Inherit Default Field Values?
Message
From
12/04/1999 09:50:10
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00207409
Message ID:
00207422
Views:
11
>Using VFP 6. I ran into a curious problem this weekend on an updatable, parameterized view. My source table has a key field with a default value of GetKeyID("TableName", "KeyName"). I pass the actual table and field name to the function.
>

Pretty standard way most people are doing it I think.

>I know the view is supposed to inherit the default value of the field in the source table but when I Insert SQL into the view, the KeyID value is 0. I do not include the KeyID field in my Insert command's field or values list in order to get the GetKeyID function called. The key id is not valued until I run the TableUpdate procedure. I am using optimistic table buffering here.
>

This I belive is a misconception... why do you think the views column would inheriet the default value setting from the field? That doesn't (nor is it supposed to) happen.


>Is this normal behaviour? I worked around this by explicitly calling my GetKeyID("TableName", "KeyName") function to return an ID and used that value in my Insert command.

Yes... it's normal behavior... if you want to 'pre-fetch' the key you can do as you are doing... OR, you can set the default value of the ID field in the VIEW as GetKeyID("TableName","KeyName"). But, if you have no reason to pre-fecth the key, it seems better to wait till there is actually a record added to the back end to generate the key. (This is close to the way you would work with SQL server. If you want to ever move to it, stick to this method.)

BOb
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform