BUG: Record Inserted Even Though the Field Does Not Accept NULL (257608)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 5.0a
- Microsoft Visual FoxPro for Windows 6.0
This article was previously published under Q257608 SYMPTOMS
When inserting a NULL value to a field that does not accept NULL, the record is inserted anyway depending upon the order of the NULL field in the table. The same behavior exists when inserting values by using the Visual FoxPro ODBC driver.
RESOLUTION
The workaround for this behavior is to create an error trapping routine to capture the error generated from the insertion of the .NULL. values and revert the table records. The following code illustrates how to accomplish this:
Paste the code below into a Visual FoxPro Program (.PRG) and run it:
CLEAR
SET MULTILOCKS ON
ON ERROR DO nullerror
CREATE TABLE myinsert ;
(col1 i NOT NULL, ;
col2 c(5) NOT NULL, ;
col3 c(5) NOT NULL)
CURSORSETPROP('Buffering', 3, 'MyInsert') && Enable Record Level Buffering
*!* These insertions will be reverted after they generate Error 1581
INSERT INTO myinsert VALUES (1, NULL, 'xxx')
INSERT INTO myinsert VALUES (NULL, 'xxx', 'xxx')
INSERT INTO myinsert VALUES (1, 'xxx', NULL)
ON ERROR
PROCEDURE nullerror
AERROR(aerrorarray) && Creates Array with Error details
IF aerrorarray(1) = 1581
WAIT aerrorarray(2) WINDOW TIMEOUT 2
TABLEREVERT()
ENDIF
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Major | Last Reviewed: | 4/4/2000 |
---|
Keywords: | kbbug kbDatabase kbDSupport kbXBase KB257608 |
---|
|