Macros inside macros

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Lithium™
Posts: 42
Joined: Wed 23 Jun 2010 06:42

Macros inside macros

Post by Lithium™ » Fri 11 May 2012 13:00

Hello!
Is there the way to use such construction as macro embedded into another macro within one DB component (TMSSQL, TMSQuery etc.)?

For example:
The value of "SQL" property is

Code: Select all

select * from &TableName
So, the Macros tab of TMSSQL component will content the one macro "TableName". If I put into value of macro "TableName" next sql code:

Code: Select all

Clients cts inner join &JoinedTable jt on cts.id = jt.client_id
I wait for macro "JoinedTable" will appear in the Macros tab too. As it's seen embedding level of macros may be many more.

Or... whether will be planned this functionality :?:

AndreyZ

Re: Macros inside macros

Post by AndreyZ » Mon 14 May 2012 07:49

Hello,

We do not plan to implement this functionality in the nearest future, but we will investigate this question. As a solution, you can use several macros, for example:

Code: Select all

procedure TMainForm.BitBtnClick(Sender: TObject);
begin
  MSQuery.SQL.Text := 'select * from &TableName1 &TableName2';
  MSQuery.MacroByName('TableName1').Value := 'tablename1';
  MSQuery.MacroByName('TableName2').Value := 'inner join tablename2 on tablename1.id=tablename2.id';
  MSQuery.MacroByName('TableName2').Active := False; // if you activate the 'TableName2' macro, you will execute a query with joined tables
  MSQuery.Open;
end;

Lithium™
Posts: 42
Joined: Wed 23 Jun 2010 06:42

Re: Macros inside macros

Post by Lithium™ » Wed 16 May 2012 06:59

AndreyZ, thank you for reply.

You show the one of possible solutions which to me is known, like some anothers that I using. I take easy example to minimize post. Real queries are much more complicated. I may provide a few examples where embedded macros are really desirable, and another solutions accompanied with code duplicating, complicating or visualisation decreasing (if necessary).
AndreyZ wrote:we will investigate this question
it suits me enough.

Post Reply