somewhat related to another snowflake question I opened In a Snowflake stored procedures, is there a way to check how many columns are in a resultSet?
Is there a way to check if a resultset is empty? For example
var query = `SELECT * FROM somewhere`
var stmt = snowflake.createStatement({sqlText: query});
var result = stmt.execute();
result.next()
var colCount = stmt.getColumnCount();
errors if there was no data returned in the resultset. It says
Failed Code 100183 State P0000 Message ResultSet is empty or not prepared, call next() first
I tried flipping it just to see what would happen.
var query = `SELECT * FROM somewhere`
var stmt = snowflake.createStatement({sqlText: query});
var result = stmt.execute();
var colCount = stmt.getColumnCount();
result.next();
It looks like both of these lines var colCount = stmt.getColumnCount();
and result.next();
throw the same error regardless of order. I suspect that the error is because result set is empty. If my suspicion is correct then I need another way to check that. Is there a safe way to check that there is any data in result at all before this error gets thrown?