https://bugs.documentfoundation.org/show_bug.cgi?id=91828
--- Comment #18 from Lionel Elie Mamane <[email protected]> --- Christian, I don't understand. You say that in LibreOffice 4.0.6.2, you got an empty string instead of a "Variant/Empty" in the variables IDString, TermID and CtxtID, and you say that then the "Statement.ExecuteQuery(Sql)" does not make an error. However, if these variables contain an empty string or they are Empty, the resulting content of variable Sql is the same, so I don't see how it can make a difference for your macro. Anyway, if you want a string, you can easily force that by adding: Dim IDString As String Dim TermID As String Dim CtxtID As String While I read your macro, I notice that in the SQL command (query), you try to compare an integer column to a string literal. This is not guaranteed to work on all database management systems. For example, it does not on PostgreSQL: ERROR: operator does not exist: integer = character HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. It happens to work with HSQLDB (or MySQL/MariaDB) because those will do automatic type conversions. I suggest that you use integers when comparing to integer. For example SELECT "Table_2"."Nr." FROM "Table_2" WHERE "Table_2"."Begriff: Nr." = 0 AND "Table_2"."Kontext: Nr." = 2 instead of SELECT "Table_2"."Nr." FROM "Table_2" WHERE "Table_2"."Begriff: Nr." = '0' AND "Table_2"."Kontext: Nr." = '2' This will be more portable. In order to avoid trying to use invalid values you could do something like: 1) Leave variables IDString, TermID and CtxtID as Variant. 2) add: if IsEmpty(IDString) OR IsEmpty(TermID) OR IsEmpty(CtxtID) Then exit sub end if before computing the value of "sql". And actually, the most robust way to do that kind of things is not to construct SQL commands on the fly, but to use parametrised queries: Option Explicit Global statement as Object Sub make_query 'Exit Sub statement = ThisComponent.DrawPage.Forms.GetByName("frm_tbl2").activeConnection.prepareStatement("SELECT ""Table_2"".""Nr."" FROM ""Table_2"" WHERE ""Table_2"".""Begriff: Nr."" = ? AND ""Table_2"".""Kontext: Nr."" = ?") End sub Sub Check_rl_term_context Dim MainForm As Object Dim Result As Object Dim Term As Object Dim IDControl As Object Dim Context As Object Dim Found As Boolean Dim IDValue As Variant Dim TermID As Variant Dim CtxtID As Variant Found = False MainForm = ThisComponent.DrawPage.Forms.GetByName("frm_tbl2") IDControl = MainForm.GetByName("Nr-Feld") Term = MainForm.GetByName("Begriff-Feld") Context = MainForm.GetByName("Kontext-Feld") TermID = Term.CurrentValue CtxtID = Context.CurrentValue if IsEmpty(TermID) OR IsEmpty(CtxtID) Then exit sub end if statement.setLong(1, termID) statement.setLong(2, CtxtID) Result = statement.ExecuteQuery() While (Not Found AND Result.Next) If (StrComp(Result.GetString(1), IDValue) <> 0) Then MsgBox("Der Begriff wurde in diesen Kontext schon eingetragen.") Term.Reset() Context.Reset() Found = True End If Wend End Sub Where "make_query" is bound to the form's "when loading" event. -- You are receiving this mail because: You are the assignee for the bug.
_______________________________________________ Libreoffice-bugs mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs
