The Free and Open Productivity Suite
Released: Apache OpenOffice 4.1.14

A sample OpenOffice basic program to write records to the Bibliographic database.

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

Option Explicit

Sub Main

' create a row set

Dim oRowSet as Object

oRowSet = createUnoService( "" )

' tell it to operate on the Bibliography/biblio table

oRowSet.DataSourceName = "Bibliography"

oRowSet.Command = "biblio"

oRowSet.CommandType =

' since we want to insert new records only, we

' can optimize the set so that it does not care for

' already existing data

oRowSet.IgnoreResult = TRUE

' fire


' let's insert the following data

Dim sTitles(4) as String

sTitles(0) = "The Hitchhiker's Guide to the Galaxy"

sTitles(1) = "The Restaurant at the End of the Universe"

sTitles(2) = "Life, the Universe and Everything"

sTitles(3) = "So Long, and Thanks for All the Fish"

sTitles(4) = "Mostly Harmless"

' for optimizations, we retrieve the column objects only once,

' and reuse them in every iteration

Dim colIdentifier as Object

Dim colTitle as Object

Dim colType as Object

Dim colAuthor as Object

colIdentifier = oRowSet.getColumns().getByName( "Identifier" )

colTitle = oRowSet.getColumns().getByName( "Title" )

colType = oRowSet.getColumns().getByName( "Type" )

colAuthor = oRowSet.getColumns().getByName( "Author" )

' now let's really insert the data

Dim i as Integer

For i = LBound( sTitles() ) To UBound( sTitles() )

' move the row set to the row dedicated to inserting data


' fill the column values

colIdentifier.updateString( "ADAMS" & ( i + 1 ) )

colTitle.updateString ( sTitles( i ) )

colType.updateString ( "1" )

colAuthor.updateString ( "Douglas Adams" )

' (note: everything which we do not change here will be

' defaulted by the underlying database, if possible)

' write the new record


Next i

' finally clean up


End Sub

Apache Software Foundation

Copyright & License | Privacy | Contact Us | Donate | Thanks

Apache, OpenOffice, and the seagull logo are registered trademarks of The Apache Software Foundation. The Apache feather logo is a trademark of The Apache Software Foundation. Other names appearing on the site may be trademarks of their respective owners.