0

I've created a PostgreSQL connection File using LibreOffice Base (6.1) and I can run SQL Queries in there just fine but I was wondering if it's possible to use this Base connection in a LibreOffice BASIC function.

I know you can use JDBC connections for MySQL

mysql://hostname:port/database_name

But I'm hoping there's a way to use the Base File seeing as it works so well

I've been trying to find documentation on this online but I am struggling to find anything that bridges the gap between BASIC and Base.

TheLovelySausage
  • 3,838
  • 15
  • 56
  • 106

1 Answers1

1

I've found the answer, the solution was to use createUnoService and that allows you to specify the name of the odb that was setup in Base.

oService = createUnoService("com.sun.star.sdb.DatabaseContext")
oBase = oService.getByName("basePostgreSQL")
oConn = oBase.getConnection("","")

oQuery = oConn.createStatement()
oSql = "select col from table"

oResult = oQuery.executeQuery(oSql)
while oResult.next()
    msgBox oResult.getString(1)
wend

oConn.close()
TheLovelySausage
  • 3,838
  • 15
  • 56
  • 106