PRB: All New Field Values Set to .NULL. When You Modify Table (130244)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0

This article was previously published under Q130244

SYMPTOMS

After executing the ALTER TABLE command to add a new field to a table or after modifying a table manually, all of the field values for a new field are set to .NULL. for each record in the table.

CAUSE

This behavior occurs if NULL is set ON by using the SET NULL command.

RESOLUTION

Issue the SET NULL OFF command before executing an ALTER TABLE command or before modifying a table manually when using the Database Container.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. From the Command window, issue the following commands:
       SET NULL ON
       CREATE DATABASE mydata
       CREATE TABLE mytable (cFld1 C(20))
       APPEND BLANK
       REPLACE cFld1 WITH "Hello"
       BROWSE
    						
  2. Browse the table to view the first record, and note the table structure. Then modify the table with an ALTER TABLE command:
       ALTER TABLE mytable ADD COLUMN cNewfld C(20)
       BROWSE
    						
Now the field value for cNewfld holds the value .NULL..

NOTE: Placing NOT NULL at the end of the ALTER TABLE command doesn't work if SET NULL is ON. Instead, the error message "Field NEWFLD does not accept null values" is displayed, and the field is not added.

Modification Type:MajorLast Reviewed:2/10/2000
Keywords:KB130244