Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
Run queries on remote PostgreSQL from LibreOffice Calc

My goal is to run simple queries from LibreOffice Calc and get the results from a remote PostgreSQL database.

I tried to do something similar to this answer but I get an error.

Here is what I have:

Sub GetQuery
   Dim oParms(1) as new com.sun.star.beans.PropertyValue 
   Dim oStatement As Object
   Dim oResult As Object
   Dim oConnection As Object

   oParms(0).Name = "user" 
   oParms(0).Value = "serveruser" 
   oParms(1).Name = "password" 
   oParms(1).Value = "serverpwd" 
   oManager = CreateUnoService("com.sun.star.sdbc.DriverManager")
   sURL = "dbname=mydatabase hostaddr=X.X.X.X port=5432 user=postgresuser password=postgrespwd"
   oConnection = oManager.getConnectionWithInfo(sURL, oParms())

   oStatement = oConnection.createStatement()
   oResult = oStatement.executeQuery("select count(*) from mytable")

   MsgBox "Result: " & oResult
   oStatement.close()
End Sub

When I try to run this I get "Object variable not set" on line oStatement = oConnection.createStatement().

As you can see I have very limited experience on remote database connection.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!