memory allocation error

The stable tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.
hyperlinx
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 15.07.2013, 07:19

memory allocation error

Postby hyperlinx » 15.07.2013, 07:36

Hello there,

I'm using ZEOSDBO-7.0.3-stable. I got this exception occasionally when inserting values using TZQuery, but other function using similar syntax just fine. so i doing some testing today, and come up something wrong in SetStatementParams().

is something wrong with this code?

Code: Select all

 Parameter := TStringList.Create;
 Parameter.Delimiter := ';';
 Parameter.QuoteChar := '"';

 Parameter.Add('PARAM1='+param1);
 Parameter.Add('PARAM2='+param2);
 Parameter.Add('PARAM3='+param3);
 Parameter.Add('PARAM4='+param4);
 Parameter.Add('PARAM5='+param5);

 MyQuery := TZQuery.Create(nil);
 MyQuery.Connection := MainForm.ConnectSQL;
 try
  SQL := 'INSERT INTO test_table0 (param1, param2, param3, param4, param5, param6, param7, param8, param9) VALUES '+
                      '(:param1, :param2, :param3, :param4, :param5, :param6, :param7, :param8, :param9)';
  MyQuery.SQL.Text := SQL;
  MyQuery.ParamByName('param1').AsString := param1;
  MyQuery.ParamByName('param2').AsString := param2;
  MyQuery.ParamByName('param3').AsString := param3;
  MyQuery.ParamByName('param4').AsString := param4;
  MyQuery.ParamByName('param5').AsString := param5;
  MyQuery.ParamByName('param6').AsString := param6;
  MyQuery.ParamByName('param7').AsString := param7;
  MyQuery.ParamByName('param8').AsString := param8;
  MyQuery.ParamByName('param9').AsString := param9;
  MyQuery.ExecSQL;
 finally
  MyQuery.Close;
  MyQuery.Free;
 end;

 Parameter.Clear;
 Parameter.Free;


by the way, i'm using mysql. using connector v5.2w through ado.

thanks in advance :roll:

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 16.07.2013, 13:15

hyperlinx,

don't understand your code here.

Parameter := TStringList.Create;
Parameter.Delimiter := ';';
Parameter.QuoteChar := '"';

Parameter.Add('PARAM1='+param1);
Parameter.Add('PARAM2='+param2);
Parameter.Add('PARAM3='+param3);
Parameter.Add('PARAM4='+param4);
Parameter.Add('PARAM5='+param5);

I don't understand the purpose of this code. What is your intention to do?


SQL := 'INSERT INTO test_table0 (param1, param2, param3, param4, param5, param6, param7, param8, param9) VALUES '+
'(:param1, :param2, :param3, :param4, :param5, :param6, :param7, :param8, :param9)';

Are the fields named as param1, param2, param3, param4, param5, param6, param7, param8, param9 ???? Or do you use different names?

MyQuery.SQL.Text := SQL;
MyQuery.ParamByName('param1').AsString := param1;
MyQuery.ParamByName('param2').AsString := param2;
MyQuery.ParamByName('param3').AsString := param3;
MyQuery.ParamByName('param4').AsString := param4;
MyQuery.ParamByName('param5').AsString := param5;
MyQuery.ParamByName('param6').AsString := param6;
MyQuery.ParamByName('param7').AsString := param7;
MyQuery.ParamByName('param8').AsString := param8;
MyQuery.ParamByName('param9').AsString := param9;
MyQuery.ExecSQL;

This part seems to be ok as long the fieldnames are corectly.
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image

hyperlinx
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 15.07.2013, 07:19

Postby hyperlinx » 30.07.2013, 12:31

i'm sorry, my code above is not simple enough... here is the one

Code: Select all

MyQuery.SQL.Text := 'INSERT INTO test_table (param1, param2, param3, param4) VALUES (:param1, :param2, :param3, :param4)';
MyQuery.ParamByName('param1').AsString := param1;
MyQuery.ParamByName('param2').Clear;
MyQuery.ParamByName('param3').AsString := param3;
MyQuery.ParamByName('param4').Value := NULL;


if param1 contain text, the operation is ok.

if i use MyQuery.ParamByName('param2').Clear then it will put string 'NULL' into table. hmm? :roll:
using this also raise mem alloc error.

if param3 is an empty string (not contain any text), it will raise exception : memory allocation error.

param4 have the same value with param2, column contain text 'NULL'


all column type is varchar(32) how to set null by insert ?

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 30.07.2013, 20:49

hyperlinx,

grumble. ADO and null values.

May i ask for the defaults of the columns? Is it possible they are declared as 'NULL'?

I was also trying to get the issues of miab3 running, see http://zeos.firmos.at/viewtopic.php?p=17686#17686

I never tryed to use MySQL-connector since the native access is loads faster than using ado. MySQL has it's own affinity like null=null but ''-is not null. I had a look to the ADOStatement. Ther was a user who di omit the null-variants. the code still exists. can you try to play with the null variants there?
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 31.07.2013, 22:23

hyperlinx,

hope i've resolved your issues. Patch done R2596 \testing-7.1 (SVN)

well you've been right. We didn't handle Null values corectly. This patch will be backported to 7.0.5 in a periode of two weeks. If you want to test it than please download 7.1 from our SVN repository.
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image

hyperlinx
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 15.07.2013, 07:19

Re: memory allocation error

Postby hyperlinx » 20.08.2013, 05:54

thank you sir, now downloading r2665, and will test it for the other codes.
seem a lot of trouble using ado, now i'm using native mysql as you suggested :mrgreen:


Return to “ZeosLib 7.0 Stable Forum”

Who is online

Users browsing this forum: No registered users and 1 guest