Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Updating CursorAdapter w/Free Tables
Message
From
15/10/2006 15:27:00
 
 
To
14/10/2006 21:38:24
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01161323
Message ID:
01162102
Views:
36
This message has been marked as the solution to the initial question of the thread.
>My understanding is that FP 2.5 free tables don't recognize nulls natively. What I understand you to say is that I would need to include all the fields (28) of the table and values for them in my UPDATE command. Is this correct? Assigning DEFAULT values to the CUSRSORSCHEMA property didn't seem to work. How would you do this?
>

Hi Tim,

Default values should work, at least they work in the code below. The code shows several scenarios when the error is expected and how to avoid it. When your "remote" source is VFP, you have an option to SET NULL OFF for the connection, then BLANK values will be used for not-assigned fields. BTW, VFP ODBC driver wasn't updated for a log time and there are some bugs that you can run into with it. I recommend you to use VFPOLEDB provider instead. If you decide to stay with VBPODBC, do not use BackgroundFetch=Yes setting.

Thanks,
Aleksey.
CLOSE DATABASES all
CLEAR
SET MULTILOCKS ON 
SET NULL ON 
?VERSION()
?
CREATE CURSOR test (f1 I NOT NULL, f2 I NOT NULL)

LOCAL oCA as CursorAdapter

oCA=CREATEOBJECT("CursorAdapter")
oCA.DataSourceType="NATIVE"
oCA.SelectCmd="SELECT f1 FROM test"
oCA.UpdatableFieldList="f1"
oCA.Tables="test"
oCA.UpdateNameList="f1 test.f1"
oCA.Alias="testCA"

? "Reason #1: The field isn't selected from the table"
?oCA.CursorFill()
SELECT testCA
APPEND BLANK 
REPLACE f1 WITH 1
IF !TABLEUPDATE()
	AERROR(aerrs)
	?aerrs[1,2]
	TABLEREVERT()
ENDIF
?
? "Reason #2: The field isn't included into UpdatableFieldList and/or UpdateNameList"
oCA.SelectCmd="SELECT f1,f2 FROM test"
?oCA.CursorFill()
SELECT testCA
INSERT INTO testCA VALUES (2,2)
IF !TABLEUPDATE()
	AERROR(aerrs)
	?aerrs[1,2]
ELSE
	? "Unexpected."
ENDIF
?"Let's include it: "
oCA.UpdatableFieldList="f1, f2"
oCA.UpdateNameList="f1 test.f1, f2 test.f2"
IF !TABLEUPDATE()
	AERROR(aerrs)
	??aerrs[1,2]
	TABLEREVERT()
ELSE
	?? "TABLEUPDATE succeeded"
ENDIF
?
? "Reason #3: The field isn't modified"
SET NULL OFF 
INSERT INTO testCA (f1) VALUES (3)
SET NULL ON 
IF !TABLEUPDATE()
	AERROR(aerrs)
	?aerrs[1,2]
ELSE
	? "Unexpected."
ENDIF
? "Let's modify the field: "
REPLACE f2 WITH 3
IF !TABLEUPDATE()
	AERROR(aerrs)
	??aerrs[1,2]
	TABLEREVERT()
ELSE
	?? "TABLEUPDATE succeeded"
ENDIF
? "Let's use DEFAULT value: "
oCA.CursorSchema = "f1 I, f2 I DEFAULT 4"
oCA.CursorFill(.T.)
SELECT testCA
SET NULL OFF 
INSERT INTO testCA (f1) VALUES (4)
SET NULL ON 
IF !TABLEUPDATE()
	AERROR(aerrs)
	??aerrs[1,2]
	TABLEREVERT()
ELSE
    ?? "TABLEUPDATE succeeded"
ENDIF
?
TABLEREVERT()
?ALIAS()
LIST
?
SELECT test
?ALIAS()
LIST
Result:
Visual FoxPro 09.00.0000.3504 for Windows

Reason #1: The field isn't selected from the table
.T.
Field F2 does not accept null values.

Reason #2: The field isn't included into UpdatableFieldList and/or UpdateNameList
.T.
Field F2 does not accept null values.
Let's include it: TABLEUPDATE succeeded

Reason #3: The field isn't modified
Field F2 does not accept null values.
Let's modify the field: TABLEUPDATE succeeded
Let's use DEFAULT value: TABLEUPDATE succeeded

TESTCA
Record#           F1          F2
      1            2           2
      2            3           3
      3            4           4


TEST
Record#           F1          F2
      1            2           2
      2            3           3
      3            4           4
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform