Hello,

First I apologize if this is off-topic. I wrote a macro that causes OO.o
to crash. I tested this on two Windows computers, with OO.o 3.0.0 and
3.0.1. There is no message from OO.o. One one system Windows reported
access violation in ntdll.dll. It crashed before a single line of the
macro sub was executed.
    I attach the failing macro module. The sub is "Vytvor_souhrn_parcel".
Furthermore I found the lines causing crash: it is the long line starting
with

    updateString = "INSERT INTO """ & ParcelySouhrnTableName & .......

However this line alone when copied to another sub does not crash OO.o.
Would you recommend rewriting this in Javascript? I don't know if I
could call a Javascript macro from a BASIC one.

Regards,
Pavel


REM  *****  BASIC  *****

const DBContextName = "PP_majetek"
const ParcelySouhrnTableName = "Parcely_souhrn"

Sub Main

End Sub


Sub Vytvor_souhrn_parcel

DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
DataSource = DatabaseContext.getByName(DBContextName)
Connection = DataSource.GetConnection("","")

Statement = Connection.createStatement()
ResultSet = Statement.executeQuery("SELECT DISTINCT ""Katastr"",""LV"" FROM 
""Parcely""") 

If IsNull(ResultSet) Then goto chyba

Statement2 = Connection.createStatement()
' Pro mySQL je lepe pouzit prikaz TRUNCATE
updateString = "DELETE FROM """ & ParcelySouhrnTableName & """"
Statement2.executeUpdate(updateString)

While ResultSet.Next
        katastr = ResultSet.getString(1)
        LV = ResultSet.getString(2)
        queryString = "SELECT ""(PK)"",""KN"",""Pozemek druh"" FROM ""Parcely"" 
WHERE ""Katastr""='" & katastr & "' AND ""LV""='" & LV & "'"
        ResultSet2 = Statement2.executeQuery(queryString)

        souhrnParcel = ""
        While ResultSet2.Next
                If souhrnParcel <> "" Then souhrnParcel = souhrnParcel & ", "
                PK = ResultSet2.getString(1)
                KN = ResultSet2.getString(2)
                druhPozemku = ResultSet2.getString(3)
                s = "KN " & KN & " - " & druhPozemku
                If PK <> "" Then s = "PK " & PK & " (" & s & ")"
                souhrnParcel = souhrnParcel & s
        Wend

        updateString = "INSERT INTO """ & ParcelySouhrnTableName & """ 
(""Katastr"", ""LV"", ""Text"") VALUES ('" & katastr & _
                                                                "', '" & LV & 
"', '" & souhrnParcel & "')"
        Statement2.executeUpdate(updateString)  
Wend


Exit Sub

chyba:
MsgBox "Došlo k neoèekávané chybì."

End Sub



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to