Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

using system variable dataset_project_id while executing stored procedure

Hi, 

Best-practice question -

When executing a stored procedure, how can I set the dataset_project_id system variable ? Is it recommended to set the variable right before the CALL of procedure or inside stored procedure by handling it as an IN param in the procedure ?

example of what I was thinking. What if the stored procedure is not in the same project of tables that am using inside the stored procedure. SHould I set the dataset_project_id inside stored procedure again to the project where the table reside ?

What if I also want to set @@project_id at session level or if I have a different billing project_id already setup in the connection object? Where does BQ look to find the dataset where procedure is and where does it look to find the dataset that is referenced inside the procedure ?

 

 

 

-- Set the default project for dataset references
SET @@dataset_project_id = 'your-project-id';
 

-- Now call the stored procedure
CALL your_dataset.your_procedure(...);

 

 

 

0 0 15
0 REPLIES 0