PostgreSQL implements the execute ... using
option to pass parameters into dynamic SQL, and as far as I can tell this feature was introduced in version 8.4. We are using Greenplum, which is forked from PostgreSQL at version 8.2, so it does not have this feature.
Is there any other way to do the same thing in Greenplum or PostgreSQL 8.2?
Best Answer
I cannot tell for sure, but there is a hint in the
CREATE FUNCTION
documentation:In turn, the referenced place says
Now the
EXECUTE ... USING
is a PL/pgSQL feature, so the only question is which PostgreSQL version it comes from. The documentation points to 8.2 - and this way it looks like you are out of luck.I've contacted the Greenplum support to get a definitive answer, but never got an answer.
As for working around the lack of that construct, you can obviously concatenate together any SQL string you want and execute it. Be careful to correctly quote the passed-in values and avoid SQL injection.