Question
· Sep 26

inserting a row into a sql server table

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

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

sc
}
 

Product version: IRIS 2022.1
$ZV: IRIS for UNIX (Ubuntu Server 20.04 LTS for x86-64) 2022.1.2 (Build 574U) Fri Jan 13 2023 15:03:40 EST
Discussion (1)1
Log in or sign up to continue