# Execute SQL that Results in Additional SQL Select Statements to be Executed

**URL:** <https://forum.cloverdx.com/t/execute-sql-that-results-in-additional-sql-select-statements-to-be-executed/1747>\
**Category:** CloverDX Platform\
**Created:** [April 28, 2016, 12:00am UTC](https://forum.cloverdx.com/t/execute-sql-that-results-in-additional-sql-select-statements-to-be-executed/1747 "2016-04-28T00:00:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmac21](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.cloverdx.com/kmac21/32/111_2.png) [@kmac21](https://forum.cloverdx.com/u/kmac21)\
**Post date:** [April 28, 2016, 12:00am UTC](https://forum.cloverdx.com/t/execute-sql-that-results-in-additional-sql-select-statements-to-be-executed/1747/1 "2016-04-28T00:00:00Z")

</div>

I am new to CloverETL and I want to execute a SQL statement that results in additional select statements to then be executed. The first statement dynamically retrieves the schemas in a Vertica database. The result statements are select statements for each schema that insert audit information into a Vertica system table.

The first statement is:  
select distinct ‘select audit(’‘’||table\_schema||‘’‘);’ from tables;

The results from the first query are, for example:  
select audit(‘schema1’);  
select audit(‘schema2’);  
select audit(‘schema3’);  
select audit(‘schema4’);  
select audit(‘schema5’);

I am using a DBInputTable component to execute the first query then sending the output as a discrete query to a DBExecute component. I am getting an error “A RowCount was expected but not generated from query”. I was reading on the forums that DBExecute does not take select statements even though in this particular case it inserts records into a system table. What can I use to execute the resulting select statements?

---

<div class="post-metadata">

**Author:** ![PedroVazquezRosario](https://avatars.discourse-cdn.com/v4/letter/p/ed8c4c/32.png) [@PedroVazquezRosario](https://forum.cloverdx.com/u/PedroVazquezRosario)\
**Post date:** [April 29, 2016, 5:04pm UTC](https://forum.cloverdx.com/t/execute-sql-that-results-in-additional-sql-select-statements-to-be-executed/1747/2 "2016-04-29T17:04:10Z")

</div>

Hi,

I would recommend that instead of using DBExecute you use another _DBInputTable_ to process your queries. The DBinputTable should have the following settings:

- D\_B connection\_ should have your Vertica connection.

- In the _Query URL_ click on _ **Port** _ tab and select your input port field (make sure your _ **Processing Type** _ is set to _ **discrete** _).

- Run your graph

---

<div class="post-metadata">

**Author:** ![kmac21](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.cloverdx.com/kmac21/32/111_2.png) [@kmac21](https://forum.cloverdx.com/u/kmac21)\
**Post date:** [April 29, 2016, 7:09pm UTC](https://forum.cloverdx.com/t/execute-sql-that-results-in-additional-sql-select-statements-to-be-executed/1747/3 "2016-04-29T19:09:03Z")

</div>

I did find a solution to my issue. I created a second DBInputTable component in place of the DBExecute component I originally had to execute the second set of select statements then have an output from there to a Trash component. This solution executes as intended.

---

<div class="post-metadata">

**Author:** ![maximo](https://avatars.discourse-cdn.com/v4/letter/m/cab0a1/32.png) [@maximo](https://forum.cloverdx.com/u/maximo)\
**Post date:** [September 24, 2016, 5:49am UTC](https://forum.cloverdx.com/t/execute-sql-that-results-in-additional-sql-select-statements-to-be-executed/1747/4 "2016-09-24T05:49:09Z")

</div>

> Hi,
> 
> I would recommend that instead of using DBExecute you use another _DBInputTable_ to process your queries. The DBinputTable should have the following settings:
> 
> - D\_B connection\_ should have your Vertica connection.
> 
> - In the _Query URL_ click on _ **Port** _ tab and select your input port field (make sure your _ **Processing Type** _ is set to _ **discrete** _).
> 
> - Run your graph
> 
> “vazquezrosariop”

Hi Pedro, I’m trying to do this but it wont let me set the processing type to discrete for some reason.

---

<div class="post-metadata">

**Author:** ![PedroVazquezRosario](https://avatars.discourse-cdn.com/v4/letter/p/ed8c4c/32.png) [@PedroVazquezRosario](https://forum.cloverdx.com/u/PedroVazquezRosario)\
**Post date:** [September 26, 2016, 3:00pm UTC](https://forum.cloverdx.com/t/execute-sql-that-results-in-additional-sql-select-statements-to-be-executed/1747/5 "2016-09-26T15:00:26Z")

</div>

Hi Maximo,

Could you please provide me with a screenshot where the error is visible. Also, what version of CloverETL are you currently running?
