Macros/Base/ba002

    From The Document Foundation Wiki
    < Macros‎ | Base
    This page is a translated version of the page Macros/Base/ba002 and the translation is 38% complete.
    Other languages:

    Descrizione

    Esegue un aggiornamento nel database corrente

    Sub main()
        doc = ThisComponent
        conn = doc.DataSource.getConnection("", "")
    </div>
    
        <div lang="en" dir="ltr" class="mw-content-ltr">
    sql = "UPDATE ""contactos"" SET ""numbers""=TRIM(""numbers"")"
        cursor = conn.prepareStatement(sql)
        result = cursor.executeUpdate()
        doc.store()
        MsgBox result
    End Sub
    def main():
        doc = XSCRIPTCONTEXT.getDocument()
        conn = doc.DataSource.getConnection('', '')
    </div>
    
        <div lang="en" dir="ltr" class="mw-content-ltr">
    sql = 'UPDATE "contactos" SET "numbers"=TRIM("numbers")'
        cursor = conn.prepareStatement(sql)
        result = cursor.executeUpdate()
        doc.store()
        print(result)  # silent if Python console is absent
        return

    Note pin.svg

    Nota:
    Input/Output to screen helps overcoming the absence of Python standard output. Python scripts can be prototyped by use of the Python shell and its Read Execute Print Loop (REPL) mechanism. Refer to Output to Consoles in order to enable such facility

    Notes