BS-9367 : CLONE - [6.1.2] And Join Gateways going into failed state

- Fix bad SQL scripts for Oracle, Postgres & SQLServer
- Fix bad renaming of a variable