(LotusScript)如何在笔记文档按钮中更新 sql?

(LotusScript)How can update sql in notes document button?

我需要更新oracle数据库中的一些字段,比如下面的代码

我设置了写值的条件,但是只能更新一条数据

如何更新条件内的数据?

Sub Click(Source As Button)
    Dim con2 As New ODBCConnection
    Dim qry2 As New ODBCQuery
    Dim result2 As New ODBCResultSet
    If con2.ConnectTo("***","***","***") Then
        Set qry2.connection = con2
        Set result2.query = qry2
        
        mysql2 = "SELECT * FROM CB_A"
        mysql2 = mysql2 + " WHERE PONUM = 'FC950102' OR PONUM = 'FT940141'"
        qry2.SQL = mysql2
        result2.Execute
        If result2.IsResultSetAvailable Then
            result2.FirstRow
            sqlponum = result2.GetValue("PONUM")
            sqlcomp = result2.GetValue("PUR_COMP_NAME")
        End If
        result2.LastRow
        For i = 1 To result2.NumRows
            result2.CurrentRow = i
            sqlponum = result2.GetValue("PONUM")
            Msgbox sqlponum + Chr(10) + sqlcomp
            If j >= 0 And k >= 0 Then
                mysql2 = "UPDATE CB_A SET ORDER_FLAG = '" + order_flag + "' , AUCTION_STATUS = '" + auction_status + "' , AUCTION_DATE = '" + tempaucdate + "' , AUCTION_PLACE = '" + AP(j) + "' , AUCTION_TIME = '" + AT(k) + "'"
                mysql2 = mysql2 + " WHERE PONUM = '" + sqlponum + "'"
                k = k + 1
                If k = 4 Then
                    j = j + 1
                    k = 0
                End If
                qry2.SQL = mysql2
                result2.Execute
            End If
        Next
    End If
    result2.Close(db_close)
    con2.Disconnect
End Sub

我编辑了一些代码来实现我想做的事情。

在 For...Next 循环中,有“result.Execute”,它将 mysql1 重置。

所以,我在 For...Next 循环中复制并粘贴了 mysql1。

然后就可以工作了

下面是最终的编码...

If con2.ConnectTo("***","***","***") Then
    Set qry2.connection = con2
    Set result2.query = qry2
    
    mysql1 = "SELECT * FROM CB_A WHERE ORDER_FLAG = '1' AND AUCTION_STATUS = '0'"
    qry2.SQL = mysql1
    result2.Execute
    result2.LastRow
    For i = 1 To result2.NumRows
        result2.CurrentRow = i
        mysql1 = "SELECT * FROM CB_A WHERE ORDER_FLAG = '1' AND AUCTION_STATUS = '0'"
        qry2.SQL = mysql1
        result2.Execute
        sqlponum = result2.GetValue("PONUM")
        sqlcomp = result2.GetValue("PUR_COMP_NAME")
        Msgbox sqlponum + Chr(10) + sqlcomp
        If j >= 0 And k >= 0 Then
            mysql2 = "UPDATE CB_A SET ORDER_FLAG = '" + order_flag + "' , AUCTION_STATUS = '" + auction_status + "' , AUCTION_DATE = '" + tempaucdate + "' , AUCTION_PLACE = '" + AP(j) + "' , AUCTION_TIME = '" + AT(k) + "'"
            mysql2 = mysql2 + " WHERE PONUM = '" + sqlponum + "' AND PUR_COMP_NAME = '" + sqlcomp + "'"
            qry2.SQL = mysql2
            result2.Execute
            k = k + 1
            If k = 4 Then
                j = j + 1
                k = 0
            End If
        End If
    Next    
End If