Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Updating a View Primary Key
Message
 
À
30/01/2006 17:49:12
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01089683
Message ID:
01092049
Vues:
34
>>>>>You could use REFRESH() function to refresh ionly the current record. I never used it so I can't asy what happens :o))
>>>>
>>>>
>>>>Refresh() what? The BizObj?
>>>
>>>He said refresh() function and meant it literally. Here's from help:
>>>
>>>REFRESH( ) FunctionSee Also
>>>CREATE SQL VIEW | CURSORGETPROP( ) | CURSORSETPROP( )
>>>Refreshes data in an updatable SQL view.
>>>
>>>REFRESH([nRecords [, nRecordOffset]] [, cTableAlias | nWorkArea])
>>>Return Values
>>>Numeric
>>>
>>>...
>>>REFRESH( ) returns the number of records refreshed.

>>
>>Did not work as expected. I´ll send you ScreenShots. Ok?
>
>The primary key is the connection between your record in the view, and the source record in the remote table. The record in the view has a zero for the key, and the saved record in the remote table has got a new key that the view doesn't know of, so it doesn't refresh. There's no record with a key of zero in the remote table, and no record with the new key value in the view. So refresh doesn't find it.
>
>What you can do, is to fetch only the last key - through a little SPT script (assuming you're still sitting on the new record in your remote view):
>
>
sqlexec(h, "SELECT @@IDENTITY AS lastkey","crsLastKey")
>replace nKey with crslastkey.lastkey in rv_myview
>use in crsLastKey
>refresh(1, "rv_myview")
>
>You'd need to know the handle (first parameter in the sqlexec() call) to do this, but I figure it can be obtained from the RV via a cursorgetprop("connecthandle").

It´s working perfectly now. I just added the code below to my Maintenance Base Class. Thank you very much.
LPARAMETERS tlAllRows, tlForce

LOCAL		lnRetVal, lnSelectedArea, lnConnectionHandle, lcPrimaryKeyField

lnRetVal = DODEFAULT(tlAllRows, tlForce)

IF lnRetVal = 0

	IF ThisForm.lAddMode

		lnSelectedArea = SELECT()

		lnConnectionHandle = CURSORGETPROP("ConnectHandle")

		= SQLEXEC(lnConnectionHandle, "SELECT @@IDENTITY AS LastKey", "crsLastKey")

		SELECT (ThisForm.pgfBizObj.Page1.CListOneToManyObj1.cGridList1.RecordSource)

		lcPrimaryKeyField = CURSORGETPROP("KeyFieldList")

		REPLACE (lcPrimaryKeyField) WITH crslastkey.LastKey

		USE IN crsLastKey

		SELECT(lnSelectedArea)
	
		ThisForm.oBizObj.Save()
		
	ENDIF
	
ENDIF

RETURN (lnRetVal)
José Augusto Cavalcanti
Global Connection
jose.cavalcanti@globalconnection.com.br
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform