BigQuery Stored Procedure - Use variable in UPDATE statement for table name

后端 未结 1 1154
你的背包
你的背包 2021-01-28 11:04

I am trying to use a while loop in a stored procedure to update a list of tables. When trying to execute the below code, I am getting the error: Table name "table_nam

相关标签:
1条回答
  • 2021-01-28 11:51

    in below fragment of script

    UPDATE table_name
    SET name = "new_name"
    WHERE name = "old_name";  
    

    you should use EXECUTE IMMEDIATE - something like below

    EXECUTE IMMEDIATE '''
    UPDATE ''' || table_name || '''
    SET name = "new_name"
    WHERE name = "old_name"''';  
    
    0 讨论(0)
提交回复
热议问题