Subscribe Bookmark RSS Feed

How can I get a script to continue executing when the condition of a portion of the script may not always be met?

christine_kim0

Community Trekker

Joined:

Jan 7, 2016

Hi,

I'm hoping someone can help with this issue I've encountered as I am stuck I have a script that works fine up until it gets to the following section of the script.  The script stops executing because the table referenced does not contain any 'Open' values.  However, this can change from day to day so one day there could be 'Open' values in the table and another day there could be none.  How can I get the script to continue executing even if the 'Open' condition isn't always met?

Data Table("Stream-QueryDetail") << Select where (:Name == "Open" & (contains(as column("Stream-QueryDetail", "QueryText"),  "IVRS/IWRS Reconciliation Query:") | (contains(as column("Stream-QueryDetail", "QueryText"),  "IVRS Reconciliation:") )

));

Thanks,

Christine

4 REPLIES
ian_jmp

Staff

Joined:

Jun 23, 2011

After the line you give, you could count how many rows were actually selected ('rs = dt << getSelectedRows') and implement some logic to control the subsequent flow of the script. Else look at the 'Try()' function. Use 'Help > Scripting Index' to find out more.

pmroz

Super User

Joined:

Jun 23, 2011

Get rows where may be easier to deal with, as you can check the number of rows in the resultant matrix.

dt = Data Table( "Stream-QueryDetail" );

search_rows = dt << get rows where(:Name == "Open" &

      (Contains( As Column( "Stream-QueryDetail", "QueryText" ), "IVRS/IWRS Reconciliation Query:" ) |

      (Contains( As Column( "Stream-QueryDetail", "QueryText" ), "IVRS Reconciliation:" ))

)

);

if (nrows(search_rows) > 0,

      // process found data here

);

txnelson

Super User

Joined:

Jun 22, 2012

Christine,

What PMroz has suggested is a good solution, however, since in your code, you are already doing a Select Where clause, I would simply add a conditional statement to control the execution:

If( N Rows( Data Table("Stream-QueryDetail") << get selected rows ) > 0, ...........)

Jim
christine_kim0

Community Trekker

Joined:

Jan 7, 2016

Great, thanks all