Wiki Home

Record Pointer


Namespace: WIN_COM_API
In trying to figure out how to work with the Auto Inc Field Type and views, I found out that the record pointer in the base table sometimes moves, sometimes doesn't. Seems that the 'base table instance' sometimes gets updated 'real time' and sometimes waits for the tableupdate(). I kind of see a pattern, but nothing I would rely on.
SET safety off
Clear
On Error ? Message()
TableRevert()
Close Databases all
Delete Database testdbc deletetables 
On error

* Create database (table and view)
Create Database testdbc
Create Table TblA (kTA_pk int primary key autoinc, cFid1 c(10) default "A" )
Insert into TblA (cFid1) values ("C")
Insert into TblA (cFid1) values ("D")
Insert into TblA (cFid1) values ("E")

Create SQL View v_TblA as ;
	select kTA_pk, cFid1, 1 as nFid2 from TblA having nFid2 = 1

DBSETPROP( "v_TblA.kTA_PK","FIELD","KeyField",.t.)
DBSetProp( "v_TblA","VIEW","SendUpdates",.t.)
DBSetProp( "v_TblA.cFid1","FIELD","Updatable",.t.)
USE in TblA
close DATABASES 
* Done with creating database

Open Database testdbc

USE TblA
? "#0", Recno('TblA'), TblA.kTA_pk, TblA.cFid1, "Normal."
use
?

Select 0
select kTA_pk, cFid1, 1 as nFid2 from TblA where kTA_pk=2 having .t. into cursor foo
? "#a1", Recno('TblA'), TblA.kTA_pk, TblA.cFid1, "moved to selected record."
select kTA_pk, cFid1, 1 as nFid2 from TblA where kTA_pk=1 having .t. into cursor foo
? "#a2", Recno('TblA'), TblA.kTA_pk, TblA.cFid1, "not moved to selected record."
?

USE in TblA
USE v_TblA
? "#b1", Recno('TblA'), TblA.kTA_pk, TblA.cFid1, "moved."
Goto 2 in TblA
USE v_TblA
? "#b2", Recno('TblA'), TblA.kTA_pk, TblA.cFid1, "not moved."
?

replace cFid1 with "F" for cFid1 = "C"
? "#c1", Recno('TblA'), TblA.kTA_pk, TblA.cFid1, "moved"
replace cFid1 with "E" for cFid1 = "D"
? "#c2", Recno('TblA'), TblA.kTA_pk, TblA.cFid1, "moved"
?
Append Blank
? "#d1", Recno('TblA'), TblA.kTA_pk, TblA.cFid1, "not moved."
replace cFid1 with "B"
? "#d2", Recno('TblA'), TblA.kTA_pk, TblA.cFid1, "not moved."
TableUpdate(1)
? "#d3", Recno('TblA'), TblA.kTA_pk, TblA.cFid1, "moved."

Return

There is also an issue if the base table is opened with a different alias. There seems to be a pattern for that too, but again, not something I would rely on. - cfk
Contributors Carl Karsten
( Topic last updated: 2003.04.24 02:23:03 PM )