Unable to execute the Teradata stored procedure due to syntax errors
Teradata doesn't support CTE in stored procedures (as of 15.00), see SQL Data Manipulation Language > The SELECT Statement > WITH and WITH RECURSIVE Statement Modifiers. Surprisingly, in some cases WITH works, but in more complex cases you get a syntax error like that.