Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Am I misusing TableUpdate()?
Message
From
15/09/1999 08:44:45
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00261437
Message ID:
00264875
Views:
57
>The code now:
>
>		public nMyBugs
>		public arMyErr
>		dimension arMyErr[1]
>		nMyBugz = AError(arMyErr)
>		lCSPResult = CursorSetProp('buffering',1,'Customers')
>		select CustUpdate
>		wait window 'ok point 1'
>		select CustUpdate
>		lnFieldCount = AFIELDS(laFields,'CustUpdate')
>		FOR nNothing = 1 TO lnFieldCount
>			wait window 'ok point 2'
>			DO CASE
>				CASE GETFLDSTATE(nNothing,'CustUpdate') = 3
>					wait window 'ok point 3'
>					SETFLDSTATE(nNothing,1,'CustUpdate')
>					wait window 'ok point 4'
>				CASE GETFLDSTATE(nNothing,'CustUpdate') = 4
>					wait window 'ok point 5'
>					SETFLDSTATE(nNothing,2,'CustUpdate')
>			endcase
>		ENDFOR
>		tableupdate(1,.t.,alias())
>	else
>	endif
>
>
>
>
>In the debugger, this is what I have in the Watch Window:
>
>
>Name / Value / Type
>
>getfldstate(nNothing,'custupdate') / 4 (in red) / N
>nNothing / 1 / N
>lCSPResult / .t. (in red) / L
>
>
>Then I click my commit button and get the error 'invalid argument etc' and the Trace window arrow is pointing to setfldstate(nNothing,2,'custupdate').
>
>The Locals window for my cmdbutton shows:
>arMyArr:
>[1,1] = 11
>[1,2] = "Function argument value, type or count is invalid"
>[1,3] to [1,7] is .NULL.
>
>nMyBugs = .f.
>nnothing = 1
>nresult = 6
>lnfieldcount = 21

Using the SETFLDSTATE function with this same exact syntax works fine for me, I can't understand what could be causing this error. You shouldn't have to but try putting an "=" in front of the SETFLDSTATE so it reads:

=SETFLDSTATE(nNothing,1,"CustUpdate")


Jim- it appears that you and I are looking at two different parts of the problem. From what Steve has told me, this is the situation:

He opens the view empty, and inserts records into it from an array. But these records are really representatives of records that already exist in the base tables, so when he does a TABLEUPDATE, he just wants to use the contents of the view to update existing records instead of insert new ones. VFP, seeing that the records in the view were inserted into the view as opposed to populated by a REQUERY(), naturally performs an INSERT SQL when the TABLEUPDATE command is given, and the result is a uniqueness error, because it is trying to add a record that already exists.

Since VFP uses the fieldstate of the contents of the view to decide how to perform the update (INSERT vs UPDATE) I have advised him to try to trick VFP using the SETFLDSTATE function to change the "new" status of the records in the view to "current", so VFP will UPDATE the base tables instead of INSERTing into them. The current state of this is an error message stemming from code that I gave him that I can't put a finger on: the code works fine for me. Any ideas along this train of thought?
















>
>
>
>At this point, my code never makes it to TableUpdate(), a few generations ago it was returning .f. and I could not see any changes in the base table.
>
>
>
>>Steve,
>>
>>You are not checking the return values from the cursorsetprop() or the Tableupdate() and either of them could be returning .F. indicating that they did not do what you asked. You still haven't told us if TableUpdate is returning .T. indicating that it did, in fact, do the update.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform