Old version of this funkcion -> wihout procedure Append.... and SetLength(TempX,...) is OK
new version - with this modification (TESTING_REV679) don't work on D2009:
Dynamic SQL error - unexp. end of command
The new version does not work with UnicodeString: The Append has a bug and Temp1 is created with garbage. The resulting SQL text is corrupted. As result, Post after Insert fails with exception message. Use the old version or fix the Append function.