Page 1 of 1

memory allocation error

Posted: 15.07.2013, 07:36
by hyperlinx
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:

Posted: 16.07.2013, 13:15
by EgonHugeist
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.

Posted: 30.07.2013, 12:31
by hyperlinx
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 ?

Posted: 30.07.2013, 20:49
by EgonHugeist
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?

Posted: 31.07.2013, 22:23
by EgonHugeist
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.

Re: memory allocation error

Posted: 20.08.2013, 05:54
by hyperlinx
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: