Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-10

MySQL5.1 and Sum(DataLength(FIELD))

9 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrew Brunner

The resulting field does not parse right.

If I execute or open the following SQL statement

SELECT SUM(LENGTH(ITMDAT)) as TesT FROM scms_ufls WHERE ITMUID=2 AND ITMKND=1

the FieldDef come back with FieldDefs count =1
The name looks good.

But if I try to access Query.Fields[0] or so, it does not exist. 1 field was supposed to be added when I build a query to sum(datalength(FIELD_NAME)) or even using the as LOCAL_FIELD_NAME should be respected to.

Thanks

Reply by email

Joost van der Sluis
to Andrew Brunner

On Sat, 2010-10-16 at 19:49 -0500, Andrew Brunner wrote:

You forgot to tell what you are doing?

The resulting field does not parse right.

Parse? Are you using the sql-parser?

If I execute or open the following SQL statement

Hmm.. probably not. Or are you accessing the MySQL api directly so that you have to parse something? Or are you just using ZEOS or maybe SQLDB and a TSQLQuery?

SELECT SUM(LENGTH(ITMDAT)) as TesT FROM scms_ufls WHERE ITMUID=2 AND ITMKND=1 the FieldDef come back with FieldDefs count =1 The name looks good.

Fielddef Fields. So what is the field-count?

But if I try to access Query.Fields[0] or so, it does not exist.

It does not exist? Do you get an error-message 'Field does not exist'?

1 field was supposed to be added when I build a query to sum(datalength(FIELD_NAME)) or even using the as LOCAL_FIELD_NAME should be respected to.

Please give some more info, maybe that I can help if you do. ;)

Joost.

Reply by email

Andrew Brunner
to Joost van der Sluis
Joost van der Sluis wrote
Hmm.. probably not. Or are you accessing the MySQL api directly so that you have to parse something? Or are you just using ZEOS or maybe SQLDB and a TSQLQuery?

Yes.. The TMySQL51 component for SQLDBLaz (svn today)

Show quoted text 6 lines
> SELECT SUM(LENGTH(ITMDAT)) as TesT FROM scms_ufls WHERE ITMUID=2 AND ITMKND=1 > > the FieldDef come back with FieldDefs count =1 > The name looks good. Fielddef Fields. So what is the field-count?

Field count always ZERO.

> But if I try to access Query.Fields[0] or so, it does not exist. It does not exist? Do you get an error-message 'Field does not exist'?

Yes. I get error. Field (even if I use precise field name in DEFs It still comes back with field not found. Even if I set name during query... still field not found.

Please give some more info, maybe that I can help if you do. ;)

Thanks. So other than using the laz TMySQL51 Connection and setting Transaction and Query to stock components I don't know what else to offer. Ask more questions :-)

Reply by email

Joost van der Sluis
to Andrew Brunner
Andrew Brunner wrote 10 lines
On Sat, Oct 16, 2010 at 8:04 PM, Joost van der Sluis wrote: >> SELECT SUM(LENGTH(ITMDAT)) as TesT FROM scms_ufls WHERE ITMUID=2 AND ITMKND=1 >> >> the FieldDef come back with FieldDefs count =1 >> The name looks good. > > Fielddef Fields. So what is the field-count? Field count always ZERO.

Then it probably doesn't recognize the field-type. But it should give an exception while opening the dataset in that case. Now I know that there are a lot of people who send in bug-reports that no exception should be given but that the fields should be ignored... But afaik this never changed. (It would be wrong, if it did)

So you are really sure you don't get an exception when you try to open the dataset? (Btw: you DID open the dataset, didn't you?)

Thanks. So other than using the laz TMySQL51 Connection and setting Transaction and Query to stock components I don't know what else to offer. Ask more questions :-)

What happens when you do a simple 'select ITMDAT as TesT from ...' ?

Joost

Reply by email

Andrew Brunner
to Joost van der Sluis
Joost van der Sluis wrote 5 lines
Then it probably doesn't recognize the field-type. But it should give an exception while opening the dataset in that case. Now I know that there are a lot of people who send in bug-reports that no exception should be given but that the fields should be ignored... But afaik this never changed. (It would be wrong, if it did)

I guess I gotta run this in debug mode an trace into the problem.

So you are really sure you don't get an exception when you try to open the dataset? (Btw: you DID open the dataset, didn't you?)

The problem happens with using transaction and execSQL or with just Query.Open. I tried both (at least last night).

What happens when you do a simple 'select ITMDAT as TesT from ...' ?

No exceptions. Just no field representing the Sum of DataLength

Reply by email

Joost van der Sluis
to Andrew Brunner
Andrew Brunner wrote
I just submitted a bug report for Lazarus. It appears that the sum statement also does not work. Count statements appear to function but sum does not.

Most probable that float or decimal fields do not work. Count returns integer fields.

But again, this should lead to an exception...

Joost.

Reply by email

Andrew Brunner
to Joost van der Sluis

They are integer fields.

Joost van der Sluis wrote 19 lines
On Mon, 2010-10-18 at 12:55 -0500, Andrew Brunner wrote: > I just submitted a bug report for Lazarus. It appears that the sum > statement also does not work. ?Count statements appear to function but > sum does not. Most probable that float or decimal fields do not work. Count returns integer fields. But again, this should lead to an exception... Joost. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email