Dynamic SQL query on record that is locked
Is there a way to perform an %Prepare()/%Execute() that will wait until the record being queried is unlocked by another process?
Ex:
Process 1 - is opening record, updating, then saving. NOTE: this is using embedded SQL
&sql(SELECT %ID INTO :id FROM table WHERE Prop=:prop)
s obj=##class(APPTRACKER.CacheHB.CustomEventCacheHB).%OpenId(eventId)
//updating record...
s sc=obj.%Save()
//simplified snippet with extra code removed
...
s sql = ##class(%SQL.Statement).%New()
s sc=sql.%Prepare("SELECT TOP 1 * FROM class WHERE Prop='"_prop_"'")
i $$$ISOK(sc) {
s rset = sql.%Execute()
i 'rset.%SQLCODE {
i rset.%Next() {
s propVal=rset.%Get(prop)
}
}
}
Product version: IRIS 2021.1