This is a script that works fine with the psql shell:
insert into tempsdf select * from source where source.id = '123';
Here are some of my tests in SqlActivity using Data-Pipelines:
Test 1: use ?
insert into mytable select * from source where source.id = ?; - works great if used with the "script" and "scriptURI" parameters on the SqlActivity object.
where is "ScriptArgument" : "123"
here? can replace the value of a condition, but not the condition itself.
Test 2: Using parameters works when a command is specified using the <script 'option
insert into #{myTable} select * from source where source.id = ?; - works fine if used only with the 'script option
insert into
- works fine if used only with the 'script option
where #{myTable} , #{myId} are parameters whose value can be declared in the template.
http://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-custom-templates.html
(when you use only parameters, make sure you delete unused scriptArguments - otherwise it will still throw an error)
FAULTS AND TESTS:
insert? select * from source, where source.id = ?;
insert? select * from source, where source.id = '123';
Both of these commands do not work, because
Table names cannot be used for placeholders for script arguments. '?' can only be used to pass values ββfor a comparison condition and column values.
Paste into # {myTable} select * from source, where source.id = # {myId}; - does not work if used as "SciptURI"
paste in tempsdf select * from the source, where source.id = # {myId}; - does not work when using ScriptURI script
Above 2 commands do not work because
Parameters cannot be evaluated if the script is stored in S3.
paste in tempsdf select * from the source, where source.id = $ 1; - does not work with 'scriptURI'
paste in tempsdf values ββ($ 1, $ 2, $ 3); - does not work.
using $ - does not work in any combination
Other tests:
"ScriptArgument": "123" "ScriptArgument": "456" "ScriptArgument": "789"
insert into tempsdf values (?,?,?); - works like a scriptURI, script and translates to insert into tempsdf values ('123','456','789');
scriptArguments will follow the order you insert and replace "?" in the script.