Page 1 of 1

Bug in tzconnection.executedirect

Posted: 24.02.2008, 19:55
by wahono
Hi All,

I use FreePascal with IDE MSEgui. I wrote this syntax to create table in MySQL 4.1 :

TZConnection1.executedirect('CREATE TABLE rentproduct (code varchar(50) NOT NULL default '', name varchar(100) default '', description varchar(100) default '', imageid longblob, PRIMARY KEY (code))');

the result table rentproduct is created but column 'name' and 'description' not created. I doubt that 'name' can't be used to be field name (but in MySQL Administrator is OK) than I change 'name' to 'name1'

TZConnection1.executedirect('CREATE TABLE rentproduct (code varchar(50) NOT NULL default '', name1 varchar(100) default '', description varchar(100) default '', imageid longblob, PRIMARY KEY (code))');

But with this way the result is 'name1 varchar(100) default ' is to be default value for field 'code'.

Is this way result same error with other compiler (Delphi, etc).

regards
wahono

Posted: 26.02.2008, 21:03
by wahono
Hi Mdaems, I try with same SQL syntax in Delphi, and result error too. This bug is causes by parsing SQL syntax. If found '' (double quote), Zeoslib translate to ' (single quote).

Original syntax :
'CREATE TABLE rentproduct (code varchar(50) NOT NULL default '', name1 varchar(100) default '', description varchar(100) default '', imageid longblob, PRIMARY KEY (code))')'

is parsed to :

'CREATE TABLE rentproduct (code varchar(50) NOT NULL default ', name1 varchar(100) default ', description varchar(100) default ', imageid longblob, PRIMARY KEY (code))')'

And surely result in database is : just 'code', 'imageid' fields is created and 'name1' and 'description' field isn't created.

wahono

Posted: 26.02.2008, 21:10
by wahono
When I posted, than I remember that I make wrong with write SQL syntax. Sorry. I should write default '' with '' for every '.

The right syntax is :

TZConnection1.executedirect('CREATE TABLE rentproduct (code varchar(50) NOT NULL default '''', name1 varchar(100) default '''', description varchar(100) default '', imageid longblob, PRIMARY KEY (code))');

Stupid me.

wahono

Posted: 26.02.2008, 22:02
by mdaems
So this whole thread can be ignored? No ExecuteDirect bug?

Posted: 26.02.2008, 22:36
by wahono
Yes, I don't see carefully. sorry.