We have a requirement where we have to do large data exports to S3 and need the app (calling the stored proc) to be able to control the file name & location.
Below stored procedure for reference.
From what I understand, the out_file cannot be a variable. And I am left with the only option of dynamic SQL. Is anyone able to confirm this? Did I miss something?
delimiter //
CREATE OR REPLACE PROCEDURE my_proc (out_file VARCHAR(255), conditions...)
AS
/*
Examples: CALL my_proc ('bucket/target', conditions...);
*/
DECLARE
BEGIN
SELECT * FROM my_table WHERE <conditions>
INTO S3 out_file
CONFIG '<redacted>' CREDENTIALS '<redacted>';
END //
delimiter ;