# Generated SQL during Report Definition execution

**URL:** <https://forums.pega.com/t/generated-sql-during-report-definition-execution/1311>\
**Category:** General\
**Tags:** reporting, 8-4-1, dev-designer-studio\
**Created:** [April 12, 2021, 11:14am UTC](https://forums.pega.com/t/generated-sql-during-report-definition-execution/1311 "2021-04-12T11:14:23Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![SatishKumarL5551](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@SatishKumarL5551](https://forums.pega.com/u/SatishKumarL5551)\
**Post date:** [April 12, 2021, 11:14am UTC](https://forums.pega.com/t/generated-sql-during-report-definition-execution/1311/1 "2021-04-12T11:14:23Z")

</div>

Hello,

We are using Pega 8.4.1. I dont see pxSQLStatementPre and pxSQLStatementPost properties on the clipboard after executing a report definition which I remember seeing in earlier versions of pega making it easy to debug any issues related to report definition behaviour.

Any reason why these are not available and how we can make them available?

Any suggestions or thoughts are appreciated.

Thanks,

Satish

---

<div class="post-metadata">

**Author:** ![AmarGajananW](https://avatars.discourse-cdn.com/v4/letter/a/b77776/32.png) [@AmarGajananW](https://forums.pega.com/u/AmarGajananW)\
**Post date:** [May 14, 2021, 11:34pm UTC](https://forums.pega.com/t/generated-sql-during-report-definition-execution/1311/2 "2021-05-14T23:34:38Z")

</div>

@SatishKumarL5551 Hi please check on you will get on pyReportContentPage for standard thread when you unit test the Report definition. I am attaching screenshot..

 ![New Bitmap Image (2).jpg](https://pega1.discourse-cdn.com/pega/original/2X/d/d9942e8195950e22aea6cce141092d39313d53e8.jpeg)

---

<div class="post-metadata">

**Author:** ![SatishKumarL5551](https://avatars.discourse-cdn.com/v4/letter/s/71c47a/32.png) [@SatishKumarL5551](https://forums.pega.com/u/SatishKumarL5551)\
**Post date:** [May 16, 2021, 10:42pm UTC](https://forums.pega.com/t/generated-sql-during-report-definition-execution/1311/3 "2021-05-16T22:42:04Z")

</div>

@AmarGajananW - Thanks for the response. I have observed pre and post sql in earlier versions of Pega. However in the current version that we are using 8.4.1 below is the snapshot of pyreportcontentpage where I dont see the generated SQL. So want to check how the generated SQL can be made available on clipboard.

 ![Report Content Page.png](https://pega1.discourse-cdn.com/pega/original/2X/7/7cc24c4156449d13e143b579e1723712e164f79e.png)

---

<div class="post-metadata">

**Author:** ![KotaC382](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/kotac382/32/2516_2.png) [@KotaC382](https://forums.pega.com/u/KotaC382)\
**Post date:** [May 17, 2021, 6:37am UTC](https://forums.pega.com/t/generated-sql-during-report-definition-execution/1311/4 "2021-05-17T06:37:37Z")

</div>

@SatishKumarL5551 Pega is not maintaining these properties (pxSQLStatementPre and pxSQLStatementPost) in pyReportContentPage from Pega 8 version. To check the Pre and Post execution queries of report definition, enable DB Query option in Tracer settings and execute the report definition.

Once report is executed switch back to tracer and navigate to SQL Query step :

For Pre SQL: Navigate to the step where Even Type is SQL: Click on the step, the query that is present in SQL attribute is Pre SQL

For post SQL : Navigate to the step where Even Type is Package Results: Click on the step, the query that is present in SQL attribute is Post SQL

---

<div class="post-metadata">

**Author:** ![Dharan](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/dharan/32/16827_2.png) [@Dharan](https://forums.pega.com/u/Dharan)\
**Post date:** [May 10, 2022, 6:36am UTC](https://forums.pega.com/t/generated-sql-during-report-definition-execution/1311/5 "2022-05-10T06:36:02Z")

</div>

@KotaC382 Is there any way to map the Pre SQL and Post SQL values to properties as these values are not on any page?

---

<div class="post-metadata">

**Author:** ![KotaC382](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/kotac382/32/2516_2.png) [@KotaC382](https://forums.pega.com/u/KotaC382)\
**Post date:** [May 11, 2022, 9:04am UTC](https://forums.pega.com/t/generated-sql-during-report-definition-execution/1311/6 "2022-05-11T09:04:24Z")

</div>

@Dharanidharan As per my knowledge we cannot because in the higher versions of Pega, these properties are removed from the Page.

---

<div class="post-metadata">

**Author:** ![BasRulesMatter](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/basrulesmatter/32/23021_2.png) [@BasRulesMatter](https://forums.pega.com/u/BasRulesMatter)\
**Post date:** [May 19, 2022, 10:55am UTC](https://forums.pega.com/t/generated-sql-during-report-definition-execution/1311/7 "2022-05-19T10:55:27Z")

</div>

@SatishKumarL5551 We have created an activity to generate the SQL of a report definition with ? parameters removed, it’s as simple as doing a trace with the DB Query option checked. We used [Database Query Extractor | Pega](https://community.pega.com/marketplace/components/database-query-extractor) but this is not working anymore from platform 8.6.3.

I can make a RAP of this activity and maybe you can make a component of it, let me know. Outline:

 ![Query merge activity steps.png](https://pega1.discourse-cdn.com/pega/original/2X/a/ab58854704da92c2db4c804f8542179dddf0e050.png)

---

<div class="post-metadata">

**Author:** ![Paula](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@Paula](https://forums.pega.com/u/Paula)\
**Post date:** [May 20, 2022, 12:20pm UTC](https://forums.pega.com/t/generated-sql-during-report-definition-execution/1311/8 "2022-05-20T12:20:17Z")

</div>

@BasG0629 Hello! Is it okay if you can also share the RAP with me? Our application is currently in 8.6.3 thus, we can’t use the one in available in Marketplace. Thank you!

---

<div class="post-metadata">

**Author:** ![BasRulesMatter](https://yyz2.discourse-cdn.com/pega/user_avatar/forums.pega.com/basrulesmatter/32/23021_2.png) [@BasRulesMatter](https://forums.pega.com/u/BasRulesMatter)\
**Post date:** [May 25, 2022, 2:49pm UTC](https://forums.pega.com/t/generated-sql-during-report-definition-execution/1311/9 "2022-05-25T14:49:57Z")

</div>

@Paula I’ll check if that works next friday! 🙂

I’ve added a .zip file containing the code to generate full SQL queries. It works as following:

1. Save the ruile in your own ruleset and remove the default input for the parameters.
2. In SQL: enter the SQL statement
3. In Inserts: entere the SQL parameters (trace DB Query events, those are stored there)

[Querymerge.zip](https://forums.pega.com/uploads/short-url/d6NSdHUsV1r72kAfUHftUVu73RO.zip) (16.1 KB)

---

<div class="post-metadata">

**Author:** ![Paula](https://avatars.discourse-cdn.com/v4/letter/p/8e8cbc/32.png) [@Paula](https://forums.pega.com/u/Paula)\
**Post date:** [June 3, 2022, 1:09pm UTC](https://forums.pega.com/t/generated-sql-during-report-definition-execution/1311/10 "2022-06-03T13:09:19Z")

</div>

Hello @BasG0629 , Thank you for sharing the zip file! I’ve tried the activity and it was working as expected from our side. This is really a big help in getting the SQL without manually inserting the bind variables. Thank you so much! 😃
