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
Empty macro or function name
Re: Empty macro or function name
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
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
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.
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
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.