Vfp When Table Is Saved Again Does the Saved Table Have the Same Record Number
Views are an Sql query and wad of parameters to help VFP effigy out what Vfp Datatypes the columns are, and what updates to ship back.
When you USE a view, VFP just executes the query stored in the SQL property of the view. If any parameters have been defined by the parameters property, VFP will prompt the user for them if there are not already values. The upshot of the query is stored in a cursor with the same name equally the view. None of the other properties have whatsoever effect on this performance. This is the extent of the SELECT function of the wapper.
Regardless of the view'south Updateable setting, yous can modify the data in this cursor. If SendUpdates is faux, none of the changes will always be written or saved, even if you do a TableUpdate(). When you close the view, the changes are lost.
If SendUpdates is marked truthful, your changes are not written anywhere either, unless a TableUpdate() is performed. At that time, a set of SQL UPDATE commands are constructed based on the properties Tables, Key Field, Updateable, UpdateName
, and WhereType
. (those are the important ones - someone else tin can add a description for UpdateType
, CompareMemo
, etc�).
The SQL UPDATE control syntax looks like this: UPDATE TableName Gear up Field1=Value1� WHERE WhereClause
. A separate update command is constructed for each record that has been modified. For this instance, lets assume that only ane tape was updated.
Looking at it in iii parts:
First the like shooting fish in a barrel i (assuming y'all are not doing anything crazy): TableName
. The name of the table being updated is stored in the Tables property of the view. Crazy can be one of two things: 1. some table other than i of the ones used in the SQL SELECT query, and 2, it tin be more than than one table, in witch case more than one update command is constructed (ane for each table), and that goes beyond what I want to write about. But for the most part, y'all merely want to update one table.
FieldN = ValueN
: for each field in the cursor that is flagged as 'updateable' and was modified (is this right??), the field name specified by the UpdateName
and the new value is used to construct the FieldN= ValueN
pair. Again, unless you are trying to exist clever, it will be the same base table and field that the cursor information came from. The implication is: yous can query from one field, and write the update dorsum to another. It is important that yous specify the proper name of the tabular array, even if there is just ane table involved. Information technology makes sense if you consider what would happen if you were updating more than 1 table.
WhereClause
: I am not sure how this affects local tables. Docs say it doesn�t, only they don�t say how local tables are handled. This is how yous debate with multi user collisions. A WhereClause
is constructed that tries to place the record by a gear up of fields and the original values of those fields. If the fields were dirtied by modifications to the view, those changes touch the Field=value function, and perhaps the WhereClause
. If someone else changes the information on the server, the tape that is being edited volition non be plant, and the UPDATE control volition not update whatever records. The server volition somehow respond with the number of record effected (0) and that is how a collision is detected.
WhereType
= 1 � Key: what ever fields are marked as key (regardless of chief alphabetize settings) are paired upwards with their original value. If there are multiple fields marked every bit key, then it is a compound key, and the expressions are ANDed. Ex: WHERE cInvno=�123� AND cItem = �1�. Every bit long as the fundamental has not been inverse, changes to this tape by other users will just exist overwritten. (no locking)
WhereType
= two � fundamental and updateable: a big honken where clause is constructed out of anything marked equally key or updateable. WHERE pkPers =123 AND cFName = �Carl� and cLName = �Karsten� and cAdd1 = �8345 Newland Av� AND �. If someone else changes whatever of these fields, the WhereClause
will not be true anymore, and so no records will be updated.
WhereType
= three � Cardinal and Modified: a smaller WhereClause
is constructed out of the PK and any fields that were modified in the view. (It even so uses the original values.) UPDATE Pers Prepare cCity = �Niles� WHERE pkPers =123 AND cCity = �Nils� (note the wrong spelling). In this case, other fields could take been inverse, but as long as the cCity field is still incorrect, the update will happen.
WhereType
= four - Key and TimeStamp
: This assumes that the back terminate has a �last modified field�. When the query was executed, a Date Time (either current server time or the last modified value of the record) is included (phone call information technology xDateTime). The WhereClause
then uses this value: WHERE pkPers =123 AND LastModified
= xDateTime. If the tape had been modified afterwards xDateTime was fix, then this will fale. This has a like affect as 2, only it is a much smaller where clause, and it includes any field in the record, not only the updateable ones.
Here is the start of some examples. someone shoudld break this upwardly and make a sample for each WhereType
.
Use V_MyView && vfp gets PK and LastUpdateTime for each record. (assume 1 and March24 1:00) Replace cName with "Carl" ** with the next command, ** vfp does this: UPDATE MyTable SET cName="Carl" ** where MyTable_pk = 1 ** and MyTable.LastUpdateTime = March24 1:00 TableUpdate()
As far as Remote Views are concerned, it is probably best to think of them every bit INCOMPLETE WRAPPERS around SQL Pass - Through -- John Petersen
How does that assistance?
Q: Is it known for a fact that deleting records in a view cause SQL DELETE commands to be issued against the backend?
A: Yes, if the view is updatable. However, ZAPing a view has no affect on the back cease. -- ?CFK
A SQL DELETE will also exist fired if the view'southward UpdateType
= two. This causes the backend to DELETE the existing record and INSERT the updated record as a new record instead of UPDATEing the existing record. - Trey Walpole
It is meliorate to UPDATE than to DELETE and then INSERT as in the latter case you may hit DELETE and INSERT triggers. -- Alex Feldstein
I agree. UPDATE likewise avoids having foreign primal constraints disallowing the parent DELETE earlier the INSERT. -- Trey Walpole
An error handler exposed this code. I think it helps explicate how the
WhereType
effects the update command. UPDATE ps!psTimeDepts Prepare cti_id=vpstimedepts.cti_id, cti_deptid=vpstimedepts.cti_deptid, cid=vpstimedepts.cid, nde_reg=vpstimedepts.nde_reg, nde_ot=vpstimedepts.nde_ot, nde_premium=vpstimedepts.nde_premium, nde_prem_ot=vpstimedepts.nde_prem_ot, nde_premvac=vpstimedepts.nde_premvac, nde_vacation=vpstimedepts.nde_vacation, nde_premsick=vpstimedepts.nde_premsick, nde_sick=vpstimedepts.nde_sick, nde_holiday=vpstimedepts.nde_holiday, nde_pt_pholi=vpstimedepts.nde_pt_pholi, nde_miles=vpstimedepts.nde_miles, nde_lisa=vpstimedepts.nde_lisa, nde_reliefhrs=vpstimedepts.nde_reliefhrs, dti_mod=vpstimedepts.dti_mod, dti_add=vpstimedepts.dti_add WHERE cti_id=OLDVAL('cti_id', 'vpstimedepts') AND cti_deptid=OLDVAL('cti_deptid', 'vpstimedepts') AND cid=OLDVAL('cid', 'vpstimedepts') AND nde_reg=OLDVAL('nde_reg', 'vpstimedepts') AND nde_ot=OLDVAL('nde_ot', 'vpstimedepts') AND nde_premium=OLDVAL('nde_premium', 'vpstimedepts') AND nde_prem_ot=OLDVAL('nde_prem_ot', 'vpstimedepts') AND nde_premvac=OLDVAL('nde_premvac', 'vpstimedep
nde_vacation=OLDVAL('nde_vacation', 'vpstimedepts') AND nde_premsick=OLDVAL('nde_premsick', 'vpstimedepts') AND nde_sick=OLDVAL('nde_sick', 'vpstimedepts') AND nde_holiday=OLDVAL('nde_holiday', 'vpstimedepts') AND nde_pt_pholi=OLDVAL('nde_pt_pholi', 'vpstimedepts') AND nde_miles=OLDVAL('nde_miles', 'vpstimedepts') AND nde_lisa=OLDVAL('nde_lisa', 'vpstimedepts') AND nde_reliefhrs=OLDVAL('nde_reliefhrs', 'vpstimedepts') AND dti_mod=OLDVAL('dti_mod', 'vpstimedepts') AND dti_add=OLDVAL('dti_add', 'vpstimedepts')
Contributors Carl Karsten Trey Walpole Alex Feldstein
See besides Local Views Remote Views Vfp Views 101
Category Data Category Client / Server
( Topic last updated: 2005.03.11 02:30:09 PM )
Source: http://fox.wikis.com/wc.dll?Wiki~VfpViews
0 Response to "Vfp When Table Is Saved Again Does the Saved Table Have the Same Record Number"
Post a Comment