Empty macro or function name

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
JimMellish
Posts: 8
Joined: Wed 06 Mar 2013 21:48

Empty macro or function name

Post by JimMellish » Thu 03 Apr 2014 09:02

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

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Empty macro or function name

Post by AlexP » Thu 03 Apr 2014 11:35

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

JimMellish
Posts: 8
Joined: Wed 06 Mar 2013 21:48

Re: Empty macro or function name

Post by JimMellish » Thu 03 Apr 2014 13:12

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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Empty macro or function name

Post by AlexP » Thu 03 Apr 2014 14:35

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.

Post Reply