dear all,
please help,
i have code for delphi 7 and use database mysql 5.1 conect with devart , as below
Close;
SQL.Text := 'INSERT INTO C'+ IntToStr(C) +
' SELECT DISTINCT ';
for i := 1 to C-1 do
SQL.Add (' P.ITEM' + IntToStr(i) +', ');
SQL.Add(' Q.ITEM' + IntToStr(C-1) +', '+
' (SELECT COUNT(O.no_nota)'+
' FROM [t_transaksijual] O '+
' WHERE(SELECT COUNT(*) FROM [t_jualdetail] D '+
' WHERE D.kode_barang IN(');
for i := 1 to C-1 do
SQL.Add (' P.ITEM' + IntToStr(i) +', ');
SQL.Add(' Q.ITEM' + IntToStr(C-1) +') '+
' AND D.no_nota = O.no_nota) >='+ IntToStr(C) +') '+
' FROM C'+ IntToStr(C-1) + ' P, C'+ IntToStr(C-1) + ' Q '+
' WHERE Q.ITEM'+ IntToStr(C-1) + ' > P.ITEM' + IntToStr(C-1) );
for i := 2 to C-1 do
SQL.Add(' AND P.ITEM' + IntToStr(i) + ' > P.ITEM' + IntToStr(i-1) );
SQL.Add(' ORDER BY ');
for i := 1 to C-1 do
SQL.Add ('P.ITEM' + IntToStr(i) +', ');
SQL.Add('Q.ITEM' + IntToStr(C-1));
try
ExecSQL;
except
end;
in error statement say it was syntax error, please help to resolve it,
thank you
tyo
error syntax
Re: error syntax
Try to analyze the generated SQL query in the debug mode. If you don't detect errors, then check this query execution in a 3rd-party tool, like dbForge. Pay attention to using the IN predicate.