Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Remote views multi-field PK
Message
De
21/07/2004 14:31:35
Mike Yearwood
Toronto, Ontario, Canada
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00926664
Message ID:
00926696
Vues:
20
Hi Mark

I meant to say all the fields that make up the PK. Will these settings remain in the DBC?



>>Hi all
>>
>>I haven't used remote views in a very long time. I've got a situation where there is no single PK field on a table. With a remote view, how do you specify that all fields are the keyfield? I know about the keyfieldlist, but I'd expect it to remain set in the view definition, but it doesn't seem to.
>
>If all the fields make up the keyfield, how could you ever issue an update on the record? Anyway, here is some code that I use to make a cursor whose source is a remote table updatable. This should give you an idea about how to set the necessary properties.
>LPARAMETERS tcCursor, tcTable
>IF VARTYPE(tcCursor) <> 'C'
>   RETURN .f.
>ENDIF
>IF VARTYPE(tcTable) <> 'C'
>   RETURN .f.
>ENDIF
>IF NOT USED(tcCursor)
>   RETURN .f.
>ENDIF
>LOCAL lnSelect
>lnSelect = SELECT()
>SELECT (tcCursor)
>CURSORSETPROP('Tables', tcTable)
>** The next property must include every remote field matched with the
>** view cursor field.
>LOCAL lcFields, lcUpdate, llRetVal
>lcFields = ''
>lcUpdate = ''
>FOR lnI = 1 TO FCOUNT(tcCursor)
>   IF NOT EMPTY(lcFields)
>      lcFields = lcFields + ', '
>   ENDIF
>   lcFields = lcFields + FIELD(lnI, tcCursor) + ' ' ;
>            + tcTable + '.' + FIELD(lnI, tcCursor)
>   IF UPPER(FIELD(lnI, tcCursor)) == 'KEYID' && PK field is not updatable
>      LOOP
>   ENDIF
>   IF NOT EMPTY(lcUpdate)
>      lcUpdate = lcUpdate + ', '
>   ENDIF
>   lcUpdate = lcUpdate + FIELD(lnI, tcCursor)
>ENDFOR
>llRetVal = CURSORSETPROP('UpdateNameList', lcFields, tcCursor)
>llRetVal = CURSORSETPROP('KeyFieldList', 'KeyID', tcCursor)
>** The next property specifies which fields can be updated.
>llRetVal = CURSORSETPROP('UpdatableFieldList', lcUpdate, tcCursor)
>** The next property enables you to send updates.
>llRetVal = CURSORSETPROP('SendUpdates', .T., tcCursor)
>llRetVal = CURSORSETPROP('UpdateType', 1, tcCursor)
>llRetVal = CURSORSETPROP('WhereType', 3, tcCursor)
>SELECT (lnSelect)
>RETURN llRetVal
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform