INSERT OR UPDATE SQL
Hi, I want to INSERT a customerID and customerName to a table if the customerID does not exist. Or UPDATE if they've changed their name.
I've reviewed the documentation (https://docs.intersystems.com/irislatest/csp/docbook/Doc.View.cls?KEY=RS...) and have confused myself with the INSERT OR UPDATE statement. Rather than using two individual statements , is there a way to get it in one?
What I have at the moment doesn't do anything. In fact it errors.
I intend to use this within a code block in a DTL.
set customerName = ##class(BAB.Utils.ExternalSystem.TransformFunctions).CustomerRecord(customerID)
&sql(INSERT OR UPDATE BAB_Production.CustomerRecords
(customerID,:customerName)
SELECT customerID
FROM BAB_Production.CustomerRecords
WHERE :customerID = customerID)
:customerID is extracted from HL7 within DTL
Thanks