Page 1 of 1

Field must have a value error

Posted: Fri 06 Mar 2009 13:41
by legende
Hi

I have a field 'staatus' which is declared NOT NULL DEFAULT ''

Query.SQL.Text := 'SELECT * FROM dept WHERE deptno=10';
Query.Edit;
Query.FieldByName('staatus').AsString := '';
Query.Post;

and then I get Error "Field 'staatus' must have a value"

Posted: Tue 10 Mar 2009 10:37
by Plash
You should set the RequiredFields property of TPgQuery to False.

Posted: Thu 12 Mar 2009 09:05
by legende
Plash wrote:You should set the RequiredFields property of TPgQuery to False.
Nope, then I get same error from database.

PgDac automaticaly replace empty string with NULL even if default is empty string, but it should not

Posted: Fri 13 Mar 2009 08:34
by Plash
When PgDAC generates an INSERT statement to add a record, only fields that have non-empty value are added to this statement. So if you don't assign a value to a field, it will get the default value.

Check that the SQLInsert property of TPgQuery is empty. In this case PgDAC generates INSERT statements at run-time.

Posted: Fri 13 Mar 2009 15:04
by legende
There are no problem with inserting data, problem exists when i want to update data and set the new value to empty string.

Posted: Tue 17 Mar 2009 13:01
by Plash
We have fixed this problem. The fix will be included in the next build of PgDAC.