Subject Re: Columnattributes T_YESNO=BOOLEAN=1,0 doesn't work if SQL contains "group by"
Author Frederic Bell
--- In IBObjects@yahoogroups.com, "clivewalden" <clivew@...> wrote:
>
> First questions:

Clive, as I already explained, the persistant Tfield definition that
results from the 2 different queries is actually different EVEN THOUGH
the query is on the same database table field!

My conclusion is that the string T_YESNO=BOOLEAN=1,0 in the
ColumnAttributes property of the TIB_CONNECTION does not do it's "job"
when there is a "group by" clause in the SQL property of a connected
TIBOQuery.

The application was converted from Paradox using the Greplace.exe.

That meant that the previous TQuery's were replaced with TIBOQuery's
without the code having to be visited in the IDE (at least, not initially)

AS I also said. The replace, along with the use of the Y_YESNO domain
in the Firebird database "CREATE DOMAIN T_YESNO AS SMALLINT DEFAULT 0
CHECK(VALUE IN ('0', '1')" along with the entry added to the
ColumnAttributes property of the IB_CONENCTION WORKS PERFECTLY without
any need for code changes to the Delphi source code (.pas)

The field definition for the POSTED field which in Paradox was defined
as Boolean is now defined as POSTED T_YESNO in the Firebird database.

the delphi Tfield definition in the Delphi code, QRYSTOCKPOSTED:
BOOLEAN has remained unchanged since it was used for paradox data and
it works perfectly well where the the QRYSTOCK SQL.TEXT = "SELECT
ACCOUNT, POSTED FROM STOCK"
BUT
it doesn't work where, on another form, the QRYSTOCK.SQL.TEXT =
"SELECT ACCOUNT, POSTED, SUM(Balance) from stock group by account,
posted", becuase in that case, the field is retrieved as a smallint
and the runtime error that result is "QryStock: Type mismatch for
field 'posted', expecting Boolean, actual smallint."

So my conclusion is that the columnattributes property of the
IB_CONNECTION CORRECTLY 'changes' the T_YESNO database fields from
smallint to Boolean Tfields at runtime BUT ONLY WHEN the query that
selected that field does not contain an aggregate clause. This is
conclusive!

Now I want somebody to fix it to save me a lot of work re-placing the
400 or so Tfield definitions where the query in question is returning
a smallint instead of a boolean.

Hope the longer description makes more sense?

>
> 1. Why is the same field defined in some places as TBooleanField and
> others as TSmallIntField? That might help with the "best" solution.
>
> 2. How is the POSTED column actually defined in the database and what
> constraints are in place?
>
> Clive
>
> --- In IBObjects@yahoogroups.com, "Frederic Bell" <freddie@> wrote:
> >
> > Columnattributes T_YESNO=BOOLEAN=1,0 doesn't work if SQL contains
> > "group by", however it DOES WORK of the SQL doesn't contain "group by"
> >
> > I am converting an extensive BDE application (not written by me).
> >
> > SQL.TEXT := 'Select account, posted, amount from DTRANS"
> > ACCOUNT: TStringField
> > POSTED: TBooleanField
> > Amount: TBCDField
> >
> > if (Posted) then // compiles fine
> >
> > SQL.TEXT := 'Select account, posted, Sum(amount) from DTRANS"
> > ACCOUNT: TStringField
> > POSTED: TSmallIntField
> > Amount: TBCDField
> >
> > if (posted) then // NOW needs to be changed to: if (posted = 1)
> >
> > The most recent grep indicates that the app contains over 400
> > 'occurances of the "group by" clause along with sundry associated .pas
> > code. That's a lot to check and fix manually! Any assistance/comments
> > appreciated. Thanks.
> >
>