---
title: "How to use macros parameter within nested SQL queries"
canonical: "https://support.appfire.com/space/SUPPORT/89133614/How%20to%20use%20macros%20parameter%20within%20nested%20SQL%20queries"
format: markdown
---
<span style="color: #000000">The </span>*<span style="color: #000000">macros</span>*<span style="color: #000000">=</span>*<span style="color: #000000">true</span>*<span style="color: #000000"> parameter has a limitation when used in nested SQL queries. </span>

<span style="color: #000000">For example, consider the following use case where </span><span style="color: #000000">the output of an outer query is fed as an input to the inner </span><span style="color: #000000">SQL </span><span style="color: #000000">query:</span>

```
select ap.directory_id,
CONCAT('{sql-query:dataSource=SQLSERVER|table=false}
use jiradbnew;
select user_name, directory_id, display_name, email_address, dir.directory_position
from cwd_user usr
join cwd_directory dir on dir."id" = usr."directory_id" and dir."id"= ', ap.DIRECTORY_ID, ' {sql-query}') as "JiraVal"
from cwd_group ap
```

<span style="color: #000000">In this case, if </span>*<span style="color: #000000">macros</span>*<span style="color: #000000"> is set to true, the inner query executes first, thus, substitution values for </span>*<span style="color: #000000">directory_id</span>*<span style="color: #000000"> is not available. Therefore, this query is not executed successfully.</span>