Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

BASE Macro SQL error when record not found

I am attempting to write a macro that uses SQL to query a table and need to determine if there is a "Not found" result. I copied the routine at https://ask.libreoffice.org/en/question/75611/handle-runtime-error-sql-macro/ but am getting a run time error.

oContext=CreateUnoService("com.sun.star.sdb.DatabaseContext")   'One service for all SQL processes
oDB1=oContext.getByName("DogDBTest1")   'get the database
oConnection1=oDB1.getConnection("","")      'establish connection to database
oConnection1.ResultSetType = com.sun.star.sdbc.ResultSetType.SCROLL_SENSITIVE   'added to allow for NRF

oResult1 = oStatement1.executeQuery(sReadReg & sRegistryID)

CursorTest = oResult1.first
If CursorTest = "False" Then
    MsgBox (sRegistryID & " Not Found"
Else    
    While oResult1.next()
       MsgBox (oResult1.getString(1) & "=String(1) " & oResult1.getString(2) & "=String(2) " _
       & oResult1.getString(5) & "=String(5)"
    wEnd

yada....... Run time error says "Property or Method not found: ResultSetType

Can anyone see errors in code or point me to alternate solution to determine if no record was found I also attempted to use ifNull solution but that didn't work either