Question
· Jan 30, 2019

How to resolve Error#6023 Query not prepared

Hi, please can you help me. I cant understand a thing on how to resolve this. I can run the query perfectly fine on SQL but when I run it in studio, it gives an error.

"0 "_$lb($lb(6023,,,,,,,,,$lb(,"Production",$lb("e^zSQLGWE
xecute+2^%Library.DynamicQueryGW.1^1","e^zExecute+14^%Library.ResultSet.1^1","e^
zIsRENAL+25^Production.FunctionSet.1^1","e^zS1+2^Production.ProcessMessageEMED.Thread1
.1^1","e^zSwitchState+90^Ens.BP.Thread.1^1","e^zOnRequest+8^Production.ProcessMessa
geEMED.1^1","e^zMessageHeaderHandler+19^IMP2HL7.ProcessMessageEMED.1^1","e^zMess
ageHeaderHandler+93^Ens.Actor.1^1","e^zOnTask+42^Ens.Host.1^1","e^zStart+62^Ens.
Job.1^2","d^StartEnsembleJob+6^|""%SYS""|STU^1","d^^^0"))))/* ERROR #6023: Query
 not Prepared. */

My code below:

set conn= ##class(%SQLGatewayConnection).%New()

set sc=conn.Connect("Production","username","password")

set sql = query here

set res =##class(%ResultSet).%New("%DynamicQueryGW:SQLGW")

set sc=res.Prepare(sql,,conn)

set sc=res.Execute()

while res.Next()

{

s RET= res.GetData(1)

}

set sc=res.Close()

set sc=conn.Disconnect()

q RET

Discussion (6)1
Log in or sign up to continue