I use it since Caché 2014.* at least.
this just the latest documentation.
What's the purpose of the semicolon ?  SELECT Name,Home_State FROM Sample.Person   ;
for TEMP table see: https://docs.intersystems.com/iris20242/csp/docbook/DocBook.UI.Page.cls?KEY=RSQL_createtable#RSQL_createtable_desc_temp

Before collecting all pieces in the Stores Procedure
I'd suggest to test you queries isolated im SMP or from terminal in SQL shell