1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd"> 3<script:module xmlns:script="http://openoffice.org/2000/script" script:name="sdbc_XResultSetUpdate" script:language="StarBasic"> 4 5 6'************************************************************************* 7' 8' Licensed to the Apache Software Foundation (ASF) under one 9' or more contributor license agreements. See the NOTICE file 10' distributed with this work for additional information 11' regarding copyright ownership. The ASF licenses this file 12' to you under the Apache License, Version 2.0 (the 13' "License"); you may not use this file except in compliance 14' with the License. You may obtain a copy of the License at 15' 16' http://www.apache.org/licenses/LICENSE-2.0 17' 18' Unless required by applicable law or agreed to in writing, 19' software distributed under the License is distributed on an 20' "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 21' KIND, either express or implied. See the License for the 22' specific language governing permissions and limitations 23' under the License. 24' 25'************************************************************************* 26 27 28 29 30 31'************************************************************************* 32' This Interface/Service test depends on the following GLOBAL variables, 33' which must be specified in the object creation: 34 35' - Global textColumn As String 36 37'************************************************************************* 38 39 40 41 42 43Sub RunTest() 44 45'************************************************************************* 46' INTERFACE: 47' com.sun.star.sdbc.XResultSetUpdate 48'************************************************************************* 49On Error Goto ErrHndl 50 Dim bOK As Boolean 51 Dim iCount As Integer 52 Dim cString As String 53 Dim colIdx As Integer 54 55 colIdx = oObj.findColumn(textColumn) 56 57 Test.StartMethod("insertRow()") 58 bOK = true 59 iCount = countRows() 60 Out.Log("Initially " + countRows() + " records") 61 oObj.moveToInsertRow() 62 oObj.updateString(colIdx, "New string") 63 oObj.insertRow() 64 Out.Log("After inserting " + countRows() + " records") 65 oObj.last() 66 bOK = bOK AND oObj.getString(colIdx) = "New string" 67 bOK = bOK AND iCount = countRows() - 1 68 Test.MethodTested("insertRow()", bOK) 69 70 Test.StartMethod("cancelRowUpdates()") 71 bOK = true 72 oObj.last() 73 oObj.updateString(colIdx, "Changed string") 74 oObj.cancelRowUpdates() 75 bOK = bOK AND oObj.getString(colIdx) = "New string" 76 bOK = bOK AND iCount = countRows() - 1 77 Test.MethodTested("cancelRowUpdates()", bOK) 78 79 Test.StartMethod("updateRow()") 80 bOK = true 81 oObj.last() 82 oObj.updateString(colIdx, "Changed string") 83 oObj.updateRow() 84 bOK = bOK AND oObj.getString(colIdx) = "Changed string" 85 bOK = bOK AND iCount = countRows() - 1 86 Test.MethodTested("updateRow()", bOK) 87 88 Test.StartMethod("deleteRow()") 89 Dim rowsBefore As Integer, rowsAfter As Integer 90 bOK = true 91 rowsBefore = countRows() 92 oObj.Last() 93 oObj.deleteRow() 94 rowsAfter = countRows() 95 Out.Log("Rows before: " + rowsBefore + ", rows after: " + rowsAfter) 96 bOK = bOK AND iCount = rowsAfter 97 oObj.Last() 98 Out.Log(oObj.getString(colIdx)) 99 Test.MethodTested("deleteRow()", bOK) 100 101 Test.StartMethod("moveToInsertRow()") 102 bOK = true 103 oObj.moveToInsertRow() 104 bOK = bOK AND oObj.getString(colIdx) = "" 105 Test.MethodTested("moveToInsertRow()", bOK) 106 107 Test.StartMethod("moveToCurrentRow()") 108 bOK = true 109 oObj.first() 110 oObj.next() 111 cString = oObj.getString(colIdx) 112 oObj.moveToInsertRow() 113 oObj.moveToCurrentRow() 114 bOK = bOK AND oObj.getString(colIdx) = cString 115 Test.MethodTested("moveToCurrentRow()", bOK) 116 117Exit Sub 118ErrHndl: 119 Test.Exception() 120 bOK = false 121 resume next 122End Sub 123Function countRows() As Integer 124 Dim iCount As Integer 125 iCount = 0 126 oObj.first() 127 while NOT oObj.isAfterLast() 128 iCount = iCount + 1 129 oObj.next() 130 wend 131 countRows() = iCount 132End Function 133</script:module> 134