question

Rahul R avatar image
0 Likes"
Rahul R asked Logan Gold edited

Will Table.query() return 0 if select count(*) query does not find any row?

Will Table.query() return 0 if the SQL query looking for count of rows for a specific condition does not find any?

Right now I get a exception - time: 0.000000 exception: FlexScript exception: Invalid row number: 1 in Table.query() result table. at MODEL:/Tools/ProcessFlow/ProcessFlow/Custom Code: Update Inventory_Details table>variables/codeNode


1651001268754.png

FlexSim 22.1.0
global table
1651001268754.png (114.0 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

·
Logan Gold avatar image
0 Likes"
Logan Gold answered Logan Gold edited

I believe if the COUNT() returns a 0, the result table will still have no rows. So for your example, you would want to do something like this:

int ASIN_Index = 0;
Table result = Table.query("SELECT COUNT(*) FROM Inventory_Details WHERE ASIN = 'DFG567'");
if (result.numRows > 0) {
     ASIN_Index = result[1][1];
}
print ("ASIN_Index: ", ASIN_Index);
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Rahul R avatar image Rahul R commented ·
Thank you
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.