Page 1 of 1

Empty macro or function name

Posted: Thu 03 Apr 2014 09:02
by JimMellish
I am getting "Empty macro or function name" when I run the following code:

UniQuery1.Sql.Text := 'select * from Agr';
UniQuery1.Open;

UniQuery2.SQL.Text := 'select * from &TableName';
UniQuery2.MacroByName('TableName').Value := UniQuery1.FieldByName('Id').AsString; //Fails

I have tried the following alternatives but they all fail with the same error:

UniQuery2.MacroByName('TableName').Value := UniQuery1.FieldByName('Id').Value; // Fails

s := UniQuery1.FieldByName('Id').AsString;
UniQuery2.MacroByName('TableName').Value := s; // Fails

Macro := UniQuery2.MacroByName('TableName');
Macro.Value := UniQuery1.FieldByName('Id').AsString; // Fails

Re: Empty macro or function name

Posted: Thu 03 Apr 2014 11:35
by AlexP
Hello,

This error can occur in case if the value retrieved in the first query contains the "{" and "}" symbols. If such symbols are present, then the table name should be quoted

Re: Empty macro or function name

Posted: Thu 03 Apr 2014 13:12
by JimMellish
Hi Alex,

Thanks for your quick reply. I now understand how this works when passing guids. With

'select * from Agr where Id = &Id'

UniQuery2.MacroByName('Id').Value := UniQuery1.FieldByName('Id').AsString
fails becuse the guid is now quoted twice; // Fails

UniQuery2.MacroByName('Id').AsString := UniQuery1.FieldByName('Id').AsString
works because the guid is quoted once.

Re: Empty macro or function name

Posted: Thu 03 Apr 2014 14:35
by AlexP
Please clarify what you mean by "now quoted twice" when using the Value property instead of AsString. Also, please provide the id field values from the first query, which causes the error.