cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Josee
Level II

If select where does not find value then do x else continue with rest of script

Hello and Happy Friday,

 

I am trying to find a way around this one. I have a part in my script where it uses the following below. The issue I have is when it does not find the value ABC in Column1. Basically, I want it to where it runs the code below but if it does not find ABC, then I want it to save a blank table (csv) and stop running the rest of the code. If it does find ABC , then I want it to continue with the rest of the code. Any help will be appreciated.

 

 

Line 1: dt << select where( :Column1 =="ABC" ););
Line 2: dt2=dt << Subset( Output Table( "ABC" ), Selected Rows( 1 ) ););

 

 

1 REPLY 1
txnelson
Super User

Re: If select where does not find value then do x else continue with rest of script

Here is a simple example script that should do what you want

dt << select where( :Column1 =="ABC" );
If( nrows(dt << get selected rows) == 0,
	dtx = new table("no rows");
	dtx << save("...........csv");
	stop();
);

dt2=dt << Subset( Output Table( "ABC" ), Selected Rows( 1 ) );
Jim