I've been using ESQL a lot but always until now with single statements. Now I want to update a System counter and receive the value back immediately before another user can change its value. I've tried the code below but with mixed results. Any help would be appreciated. By the way, it's ODBC using a Pervasive V11 backend running in DF 18.2 .
Code:
      If (hdbc <> 0) Begin
            Get SQLOpen of hdbc to hstmt
            If (hstmt <> 0) Begin 
                Move "UPDATE SYSFIELD SET VALUE=(VALUE+1) WHERE NAME='LAST_EMAIL'"  to sQueryStr1 
                Move "SELECT VALUE FROM SYSFIELD WHERE NAME ='LAST_EMAIL'"          to sQueryStr2
       // Either this ---------------------------------------------------------------------------------
                Send SQLExecDirect of hstmt (sQueryStr1+";"+sQueryStr2)  //Only the first Statement is executed
       // Or this ------------------------------------------------------------------------------------------
                Send SQLExecDirect of hstmt sQueryStr1    // }This works but is this approach safe in a multi-user environment? 
                Send SQLExecDirect of hstmt sQueryStr2    // }
                
                Repeat
                    Get SQLFetch of hstmt to iFetchResult
                    If (iFetchResult <> 0) Begin
                       Get SQLColumnValue of hstmt 1 to iCode 
                    End
                Until (iFetchResult = 0)
                Send SQLClose of hstmt
            End
            Send SQLDisconnect of hdbc
      End
Ian