The Free and Open Productivity Suite
Apache OpenOffice 4.1.7 released

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 Events

Apache Software Foundation

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

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