>>>>(.t.) ". At this point the local view source table (People) is updated with all fields from the local view except for the key field (people_id). The key field (people_id) is correct in the local view but blank in the source table.
>>>>
>>>>This of course causes an update conflict when the second new reord is added, because both have blank keys.
>>>>
>>>>I made the key field updatable in the local view. This does not help. Local view has "Send SQL updates" checked, SQL where clause includes "SQL Key fields only" and Update using "SQL Update".
>>>>
>>>>I feel this is just a small thing I have overlooked, but I cannot pin down what it is.
>>>
>>>Is this a multi-table view? You might want to generate and look at the view code to see if anything unusual is happening.
>>>
>>>Dan
>>
>>No this is the simplest of views :
>>
>>SELECT *;
>> FROM people;
>> WHERE People.address_id = ?address.address_id
>
>Can you post the code including all the update code. If you don't have code that will gen the views, I believe that Erik Moore has some code in the files section that handles this.
>
>Dan
here it is --
** procedure locView
lparameter tcTableName,tcViewName,tcFilterCond
local ;
lnPara,;
cIDField,;
cViewname,;
lFitlerCond
lnPara = pcount()
do case
case lnPara = 1
tcViewName = ""
tcFilterCond = ".t."
lFitlerCond = .f.
case lnPara = 2
** this is OK
tcFilterCond = ".t."
lFitlerCond = .f.
case lnPara = 3
lFitlerCond = .t.
otherwise
** this is bad
assert .f. message ;
BADPARAMETERS_LOC+" Proceudre locView "+WILLRETURN_LOC
endcase
tcTableName = lower(juststem(tcTableName))
cIDField = upper(alltrim(left(tcTableName,7)) + "_id")
cFromTabFile = tctableName
if empty(tcViewName)
tcViewName = proper(alltrim(left(tcTableName,7)) + "_lv")
endif
if lFitlerCond
create sql view (tcViewName) ;
as select * from &cFromTabFile ;
where &tcFilterCond
else
create sql view (tcViewName) ;
as select * from &cFromTabFile
endif
DBSetProp(tcViewName, 'View', 'UpdateType', 1)
DBSetProp(tcViewName, 'View', 'WhereType', 1)
DBSetProp(tcViewName, 'View', 'FetchMemo', .T.)
DBSetProp(tcViewName, 'View', 'SendUpdates', .T.)
DBSetProp(tcViewName, 'View', 'UseMemoSize', 255)
DBSetProp(tcViewName, 'View', 'FetchSize', 100)
DBSetProp(tcViewName, 'View', 'MaxRecords', -1)
DBSetProp(tcViewName, 'View', 'Tables', 'equip')
DBSetProp(tcViewName, 'View', 'Prepared', .F.)
DBSetProp(tcViewName, 'View', 'CompareMemo', .T.)
DBSetProp(tcViewName, 'View', 'FetchAsNeeded', .T.)
DBSetProp(tcViewName, 'View', 'FetchSize', 100)
DBSetProp(tcViewName, 'View', 'Comment', "Local View built by Program LocView")
DBSetProp(tcViewName, 'View', 'BatchUpdateCount', 1)
DBSetProp(tcViewName, 'View', 'ShareConnection', .F.)
select (tcTableName)
dime aFlds(1)
nNoFields = afield(aFlds)
for lnKnt = 1 to nNoFields
lcFieldName = tcViewName + "." + aFlds(lnKnt,1)
lcUpdateField = tcTableName + "." + aFlds(lnKnt,1)
lcFieldType = aFlds(lnKnt,2) + ;
"(" + alltrim(str(aFlds(lnKnt,3)) + ")" )
if aFlds(lnKnt,1) = cIDField
DBSetProp(lcFieldName, 'Field', 'KeyField', .t.)
DBSetProp(lcFieldName, 'Field', 'Updatable', .f.)
else
DBSetProp(lcFieldName, 'Field', 'KeyField', .f.)
DBSetProp(lcFieldName, 'Field', 'Updatable', .t.)
endif
DBSetProp(lcFieldName, 'Field', 'UpdateName', lcUpdateField)
DBSetProp(lcFieldName, 'Field', 'DataType', lcFieldType)
endfor
Best Regards
Don Simpson