Subject Posting a new record to a Dataset linked to a TIB_Grid - the end
Author Roberto Freitas
I finally resolved the problem following Woody's track.
At end of BeforePost event, I have watched IB_QueryConta InsertSQL
property's value and it's equal to ''
Looking at TIB_Monitor, the real Insert statement doesn't have field
cct_ciireg, but only fields that are on the TIB_Grid (cct_ciireg is
one of the fields whose value is assigned on code, not on grid,
because it is in the Query but not in the grid).
At end of BeforePost event, I have filled in the IB_Query Insert
property with the statement I want to submit to the server. AND IT'S
FINE, NOW.
These are the strings from TIB_Monitor:

INSERT INTO CONTA
( CCT_CONTA
, CCT_TITULO
, CCT_TIPO
, CCT_CUSCOD
, CCT_ORDEM
, CCT_RATEIO)
VALUES
( ? /* CONTA.CCT_CONTA */
, ? /* CONTA.CCT_TITULO */
, ? /* CONTA.CCT_TIPO */
, ? /* CONTA.CCT_CUSCOD */
, ? /* CONTA.CCT_ORDEM */
, ? /* CONTA.CCT_RATEIO */ )

FIELDS = [ Version 1 SQLd 0 SQLn 30 ]
----*/
/*---
[ 16/09/2005 07:02:11 ]
EXECUTE STATEMENT
TR_HANDLE = 14164468
STMT_HANDLE = 14166400
PARAMS = [ Version 1 SQLd 6 SQLn 6
CONTA.CCT_CONTA = '110103018'
CONTA.CCT_TITULO = 'teste'
CONTA.CCT_TIPO = 'A'
CONTA.CCT_CUSCOD = 'teste'
CONTA.CCT_ORDEM = 0
CONTA.CCT_RATEIO = 0 ]

ERRCODE = 335544347
----*/
/*---
[ 16/09/2005 07:02:11 ]
INTERPRET BUFFER =

ERRCODE = 60
----*/
/*---
[ 16/09/2005 07:02:11 ]
INTERPRET BUFFER = validation error for column CCT_CIIREG, value "***
null ***"

ERRCODE = -1
----*/
/*---

For good understanding of all this stuff, this is my original
question:

I am using a TIB_Grid linked to a TIB_DataSource and a TIB_Query.
I have this code at IB_QueryContaAfterInsert event:
with IB_QueryConta do
begin
...
FieldByName('cct_ciireg').AsString := Gl_ciireg_f;
...
end;
Im this case, Gl_ciireg_f = '10010001'
For a new record, the user types values for other fields on the
TIB_Grid. Field cct_ciireg is not visible on the grid, so user cannot
change it.
I checked that the code above actually executes.
I watched FieldByName('cct_ciireg').AsString in 2 different places:
at end of IB_QueryContaAfterInsert event and
at end of IB_QueryContaBeforePost event
In both places, the value is correct = '10010001'
Although, when posting record, I got this ISC Error Message:
ISC ERROR CODE: 335544347
validation error for column CCT_CIIREG, value "***null***"
If FieldByName('cct_ciireg').AsString = '10010001' just before post
record (IB_QueryContaBeforePost event), how can I get this error?