I have written one store procedure that runs multiple Queries with select
and show
keywords. Below is the sample query that I am running.
sq := 'SHOW FUTURE GRANTS IN DATABASE ' || :database_name;
EXECUTE IMMEDIATE (sq);
future_obj := (SELECT OBJECT_AGG(REPLACE("grant_on" ||'S','_',' '),TO_VARIANT(UPPER("grantee_name")))
FROM TABLE(RESULT_SCAN(LAST_QUERY_ID()))
WHERE "privilege" = 'OWNERSHIP' AND "grant_to" = 'ROLE' GROUP BY "grant_to");
when I run the store procedure where I have only one warehouse it runs perfectly fine but when I run the same script where we have multiple warehouses it gives me the below error.
How I can pass the warehouse, I have tried to execute ‘USE WAREHOUSE ‘ but it also not working.
I am running this store procedure with the Accountadmin
role. It requires running with same role.
Uncaught exception of type 'STATEMENT_ERROR' on line 166 at position 15: No active warehouse selected in the current session. Select an active warehouse with the 'use warehouse' command.