I have my main data table broke down in to few tables using subset function. Then I am doing some operations and trying to merge them back using the update function. But sometime time I only have one table and sometimes 2 tables. How can I tell script to continue if second table doesn't exist.
// Update data tables
Data Table( "Material A" ) << Update(
With( Data Table( "Material B" ) ),
Match Columns( :SN = :SN )
How can I tell script that if Material A or Material B table not exist, still continue execution.
You could use Try-statement or you could check if those tables exist before updating. Personally I would perform a check instead of relying on Try. Also usually it is better to use variables to store references to tables instead of relying on the table names.
Edit: Using Try would look something like this (https://www.jmp.com/support/help/en/17.2/#page/jmp/throw-and-catch-exceptions.shtml)
Try(
Data Table("Big Class") << Update(
With(Data Table("Big Class Families")),
Match Columns(:name = :name)
)
);
and check for table names
tablelist = Get Data Table List() << get name;
// Only join if both are found
If(Contains(tablelist, "Big Class") & Contains(tablelist, "Big Class Families"),
Data Table("Big Class") << Update(
With(Data Table("Big Class Families")),
Match Columns(:name = :name)
)
);
You could use Try-statement or you could check if those tables exist before updating. Personally I would perform a check instead of relying on Try. Also usually it is better to use variables to store references to tables instead of relying on the table names.
Edit: Using Try would look something like this (https://www.jmp.com/support/help/en/17.2/#page/jmp/throw-and-catch-exceptions.shtml)
Try(
Data Table("Big Class") << Update(
With(Data Table("Big Class Families")),
Match Columns(:name = :name)
)
);
and check for table names
tablelist = Get Data Table List() << get name;
// Only join if both are found
If(Contains(tablelist, "Big Class") & Contains(tablelist, "Big Class Families"),
Data Table("Big Class") << Update(
With(Data Table("Big Class Families")),
Match Columns(:name = :name)
)
);
Thanks for the solutions and advice to use variables to store references to tables instead of relying on the table names.
If you use variables then you could also use Is Empty(dtref)
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
Try(dt2 = Open("$SAMPLE_DATA/Big Class Families"));
Show(Is Empty(dt), Is Empty(dt2));
but you might have to use other methods, depending where you are getting your tables (you can figure out a way to use Try() if nothing else seems to work).