The size of that SQL is around 8807 characters, you need to bring it down to 8190 which is the max chars allowed. You might get lucky by using single letter aliases for all your joins, you only used single letter aliases for one or two tables. You can also trim the statement further more by issuing a SET DATABASE TO amline prior to executing the SQL, thus you would not need the amline!, and then restore whichever was the selected database.
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?
"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare
"To die for a religion is easier than to live it absolutely"
Jorge L. Borges