i am trying to embed a dynamic SQL into Objectscript code , but the %NEXT() will return 0 , however when i copy the same query and run it in the SQL bit it will give me the result i want
the code :
set myquery = "SELECT"
set myquery = myquery_" $PIECE(Substring(M.Rawcontent,Charindex('PD1|',M.Rawcontent),1000),'|',4),"
set myquery = myquery_" H1.TargetConfigName,"
set myquery = myquery_" H.Timecreated,"
set myquery = myquery_" H.MessageBodyId"
set myquery = myquery_" FROM"
set myquery = myquery_" Ens.MessageHeader H"
set myquery = myquery_" left outer join Enslib_HL7.Message M ON (H.MessageBodyId=M
.png)


.png)

.png)
.png)
.png)
.png)