Well you can have more than one cursor. The main problem is in the second query, we joined Ens.Messageheader to EnsLib_HL7.Message and referencing the Identifier field of EnsLib_HL7.Message was causing a compiler error on the SQL query. Once that field was removed, everything is fine. The oddity is the query would work fine on the Management Portal SQL web page, but would not work in code.

The error was  multiple Referenced macro not defined errors.