【问题标题】:(LotusScript)How can update sql in notes document button?(LotusScript)notes文档按钮如何更新sql?
【发布时间】:2021-02-09 05:40:50
【问题描述】:

我需要更新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

【问题讨论】:

  • 使用调试器单步执行代码时会是什么样子?这应该向您展示代码中发生了什么。您还应该使用 Option Declare,然后声明所有变量。

标签: lotus-notes lotusscript


【解决方案1】:

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

在 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

【讨论】:

    猜你喜欢
    • 2013-02-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多