I have a script that has multiple redshift unload statements
UNLOAD('SELECT * FROM test.products WHERE product_name LIKE \'%20160912%\'') TO 's3://test-bucket/products/20160912/prod_' CREDENTIALS 'XXXX' DELIMITER AS '|' parallel off; There are multiple such statements. I want to parameterize the date and pass in the date when I run this script. How can I do this?
The script would be like this
UNLOAD('SELECT * FROM test.products WHERE product_name LIKE \'%${DATE}%\'') TO 's3://test-bucket/products/${DATE}/prod_' CREDENTIALS 'XXXX' DELIMITER AS '|' parallel off; Is there a way to replace ${DATE} when I run the script. I know there is PREPARE in Redshift but my thought is it cannot work with the Unload statement. Another option is to write a shell script and have the shell script call this SQL script. But is there an easier way to just pass in the parameter when running the SQL script from the command line.
Thanks in advance for the help!