Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Updating CursorAdapter w/Free Tables
Message
From
15/10/2006 04:49:24
 
 
To
14/10/2006 21:28:21
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01161323
Message ID:
01162068
Views:
26
>>AERROR, BTW, says that one of the fields in the underlying table will not accept nulls. So the insert appears to be failing b/c one of the fields that I'm not assigning a value to thinks I'm trying to assign a null. Do you see anything that might cause the Insert to fail to the free table? Do you know of anything that limits the usage of free tables in CursorAdapters?
>>
>
>Hi Tim,
>

Hi Aleksey,

>I don't think the error is caused by the fact that you are working with a free table.

mmm. With a dbc's table, you can define a DEFAULT '', and then the error don't happen, the FREE is relevant.

>For a new record, non-modified fields are not included by CursorAdapter into INSERT command.

mmm. except with a SETFDL() revert,
how can I insert a record without having modified fields ?

>If one of those omitted fields happens to be a non-NULL >field in the table, you may get the error you describe. Make sure to assign values to the fields like that before doing TABLEUPDATE.

with patience, can you study this repro.
For me this is a BIG BUG.
* null is the insert default
SET NULL ON
SET NULLDISPLAY TO 'NULL'

SQLDISCONNECT(0)

CLOSE DATABASES ALL

CLOSE TABLES ALL
CLEAR

ERASE custser.DBF

CREATE TABLE custser FREE ;
(	CUSTSERID I;
,	F1	C(7) 			NULL		;
,	F2	C(7) 			NOT NULL	;
,	F3	C(7) 			NULL		;
,	F4	C(7) 			NOT NULL  )

* empty
BROWSE LAST

USE

TEST()

PROCEDURE test

SET MULTILOCKS ON

WITH CREATEOBJECT('cursoradapter') AS CursorAdapter
  .Alias = 'vCACS'
  .BREAKONERROR = .t.
  .AllowInsert=.T.
  .AllowUpdate=.T.
  .BufferModeOverride= 5
  .KeyFieldList = 'CustSerID'
  .NoData = .T.
  .Prepared = .F.
  .Tables = 'CustSer'
  .UpdateType= 1
  .UseCursorSchema = .T.
  .SendUpdates = .T.
  .WhereType = 3
	.DataSourceType = 'ODBC'
	   
  .CursorSchema = ;
    [CUSTSERID I	;
    ,	F1	C(7)	DEFAULT 'Aleksey'	;
    ,	F2	C(7)	DEFAULT 'Aleksey'	;
    ,	F3	C(7)	DEFAULT 'Aleksey'	;
    ,	F4	C(7)	DEFAULT 'Aleksey'	]

	
  .DATASOURCE= SQLSTRINGCONNECT([DSN=Visual FoxPro Tables;UID=;PWD=;] + ;
    [SourceDB=]+SET("DIRECTORY")+[;SourceType=DBF;Exclusive=No;] + ;
    [BackgroundFetch=Yes;Collate=Machine;])

  .SelectCmd = [select custserid, F1, F2, F3, F4 from custser WHERE custserid = ?M.gnCustSerID]

  * F3 and  F4 are skipped
  
  .UpdatableFieldList = [CUSTSERID, F1, F2]
  
  .UpdateNameList =[CUSTSERID custser.custserid	;
  	,	F1 custser.F1	;
  	,	F2 custser.F2	]
  	
  IF  .CursorFill(.T.,.T.)

		* insert custserid only
		INSERT INTO vcacs (custserid) VALUES (1)
		
		* 34444
		? GETFLDSTATE(-1)
		
		* expected a F4 error, but VFP fill it with a empty, without errors
		IF NOT  TABLEUPDATE(1)
			? "step 1: ",MESSAGE()
			=TABLEREVERT(.T.)
		ENDIF

		* TRY WITH SETFLDSTATE, expected same behaviour
		
		INSERT INTO vcacs (custserid) VALUES (2)
		
		SETFLDSTATE('F4',3)
		* 34443
		? GETFLDSTATE(-1)

		IF NOT  TABLEUPDATE(1)
			? "step 1: ",MESSAGE()
			=TABLEREVERT(.T.)
		ENDIF


		.CursorDetach 

	ENDIF

	 SQLDISCONNECT(.DATASOURCE)	

	* local cursor is empty !!
	BROWSE LAST			
ENDWITH

SQLDISCONNECT(0)

CLOSE DATABASES ALL

CLOSE TABLES ALL

* It seems me that there am a great bug ( on VFP ODBC ? )
* the program fail 2 tableupdate()
* and do 2 tablerevert,
* result is a empty local cursor,
* BUT THE SOURCETABLE is filled with 2 records
* and F4 is EMPTY !!! 

* 1	Aleksey	Aleksey	NULL BLANK
* 2	Aleksey	Aleksey	NULL BLANK

USE custser
BROWSE LAST

* next fire the standard ( Bad  design !) error F4

INSERT INTO custser (custserid) VALUES (3779862)

BROWSE LAST
Fabio


>
>Thanks,
>Aleksey.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform