I am trying to insert a single row into an external MS SQL Server table. I have set up the SQL Gateway. The insert query runs, but it is inserting an extra row each time.
What am I missing:
#include %occInclude
set gc = ##class(%SQLGatewayConnection).%New()
if gc = $$$NULLOREF quit $$$ERROR($$$GeneralError, "Can not create sql gateway connection.")
set pDSN = "xxxx"
set usr = "xxx"
set pwd = "xxxx"
set sc = gc.Connect(pDSN,usr,pwd,0)
if $$$ISERR(sc) quit sc
if gc.ConnectionHandle = "" quit $$$ERROR($$$GeneralError,"connection failed") set sc=gc.AllocateStatement(.hstmt)
if $$$ISERR(sc) quit sc
s pQuery="insert into testRx (RxIndex, PatientName, PatientStreet1, PatientCity, PatientState, PatientZipCode, PatientPhoneNumber, DrugName, DrugId, Quantity, DaysSupply, RefillText, Provider, SiteId) values ('500-12345-1','test,one','123 oak st','reno','nv','99999','5555555555','aspirin 81mg','A0008','90','90','(1of5)','provider,one','500')"
set sc = gc.Prepare(.hstmt,pQuery)
if $$$ISERR(sc) quit sc
set sc = gc.Execute(hstmt)
if $$$ISERR(sc) quit sc
Q sc
}