I'm testing the spatial possibilties in MySQL. For this purpose I have defined a table as follows:
.................................................................................................
CREATE TABLE `myspatial` (
`ETYPE` varchar(15) default NULL,
`LAYER` varchar(100) default NULL,
`COLOR` int(11) default NULL,
`LINETYPE` varchar(100) default NULL,
`LTSCALE` double default NULL,
`THICKNESS` double default NULL,
`geom` geometry default NULL,
`H` geometry default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
................................................................................................
The following code fragment shows how I try to populate the table with data.
;...................................................................................................
with Form1 do
begin
ZQuery1.SQL.Clear;
ZQuery1.Close;
with ZQuery1.SQL do
begin
add('insert into MySpatial (EType, Layer, Color, LineType, LTScale, Thickness, geom) values (');
add(IntToStr(NN.EntityType));
add(', ' + NN.Layer);
add(', ' + IntToStr(NN.Color));
//add(', ' + NN.LineType);
add(', ' + '141');
add(', ' + FloatToStr(NN.LineTypeScale));
add(', ' + FloatToStr(NN.Thickness));
add(', ' + 'GeomFromText' + strKoordList + ')');
//add(')');
end;
ZQuery1.ExecSQL;
end;
.............................................................................................
if the values for LAYER and LINETYPE consists of strings with only numbers
the table will be updated, but if there is also letters the call will fail.
Using SQLYOG I can give these fields also alfanumeric values.
Is this a bug in ZEOS??
I'm using ZeosDBO 6.5.1-alpha CVS release as of 13/10/2005 and
MySQL 5.1
//Alf
Help me understand this...
Moderators: gto, cipto_kh, EgonHugeist
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Hi Alf,
Just add quotes to your statement!! If you print the string you are creating ( Showmessage(ZQuery1.Sql.text); ) You will see the strings are not quoted.
Try to build the exact text -including quotes and brackets- you passed to SQLYog before calling ExecSQL.
If that doesn't work right away use the sqlmonitor component to see what statement is exactly sent to the server.
Mark
Just add quotes to your statement!! If you print the string you are creating ( Showmessage(ZQuery1.Sql.text); ) You will see the strings are not quoted.
Try to build the exact text -including quotes and brackets- you passed to SQLYog before calling ExecSQL.
If that doesn't work right away use the sqlmonitor component to see what statement is exactly sent to the server.
Mark
Thanks Mark, your help was very valuable. I have altered my code and now it works well.
........................................................
with Form1 do
begin
ZQuery1.SQL.Clear;
ZQuery1.Close;
with ZQuery1.SQL do
begin
add('insert into MySpatial (EType, Layer, Color, LineType, LTScale, Thickness, geom) values (');
add('"' + IntToStr(NN.EntityType) + '"');
add(', ' + '"' + NN.Layer + '"');
add(', ' + '"' + IntToStr(NN.Color) + '"');
add(', ' + '"' + NN.LineType + '"');
add(', ' + '"' + FloatToStr(NN.LineTypeScale) + '"');
add(', ' + '"' + FloatToStr(NN.Thickness) + '"');
add(', ' + 'GeomFromText' + strKoordList + ')');
end;
//ShowMessage(ZQuery1.SQL.Text);
ZQuery1.ExecSQL;
end;
........................................................................................................
I do not understand how to use the SQLMonitor component. What do I have to write in the File Name property? Can you give me an example please?
//Alf
........................................................
with Form1 do
begin
ZQuery1.SQL.Clear;
ZQuery1.Close;
with ZQuery1.SQL do
begin
add('insert into MySpatial (EType, Layer, Color, LineType, LTScale, Thickness, geom) values (');
add('"' + IntToStr(NN.EntityType) + '"');
add(', ' + '"' + NN.Layer + '"');
add(', ' + '"' + IntToStr(NN.Color) + '"');
add(', ' + '"' + NN.LineType + '"');
add(', ' + '"' + FloatToStr(NN.LineTypeScale) + '"');
add(', ' + '"' + FloatToStr(NN.Thickness) + '"');
add(', ' + 'GeomFromText' + strKoordList + ')');
end;
//ShowMessage(ZQuery1.SQL.Text);
ZQuery1.ExecSQL;
end;
........................................................................................................
I do not understand how to use the SQLMonitor component. What do I have to write in the File Name property? Can you give me an example please?
//Alf
file name is for saving logs into file. Here is my code adding new lines into memo
zsqlmonitor/events/ontrace:
yea i cut some stuff bcs dont wanna trace some string from trace log.
zsqlmonitor/events/ontrace:
Code: Select all
procedure TMDIChild.ZSQLMonitor1Trace(Sender: TObject;
Event: TZLoggingEvent; var LogTrace: Boolean);
var
g: integer;
linia: string;
begin
linia:=Event.AsString;
if Pos('msg:', linia) > 0 then begin
g:=pos('msg:', linia);
linia:=copy(linia, g+5, length(linia));
end;
linia:=stringreplace(linia,#13#10,' ',[rfIgnoreCase, rfReplaceAll]);
memo2.Lines.Add(linia);
end;