Hello!
I have a connection to an external datasource (Oracle DataBase) via ODBC driver in Calc.
oManager = CreateUnoService("com.sun.star.sdbc.DriverManager")
sURL$ = "sdbc:odbc:proddb"
AppendProperty(oParams(), "user", sUser)
AppendProperty(oParams(), "password", sPass)
AppendProperty(oParams(), "JavaDriverClass", "com.sun.star.comp.sdbc.ODBCDriver")
oCon = oManager.getConnectionWithInfo(sURL, oParams())
To get results from DB, I execute a prepared statement:
sSqlString = "select t.nmbr n, sum(t.amnt1) g4, sum(t.amnt2) g5, sum(t.amnt3) g6, sum(t.amnt4) g7, sum(t.amnt5) g8, sum(t.amnt6) g9, sum(t.amnt7) g10, sum(t.amnt8) g11
from table t
where ..."
oSqlStatement = oCon.prepareStatement(sSqlString)
For i = 1 To UBound(ParamList)
setVar(oSqlStatement, i, ParamList(i))
Next i
oResult = oSqlStatement.executeQuery()
The result includes sums of big numbers, so they are expected to be long integers (8+ digits).
And then when I try to get values from my ResultSet, they end up being in scientific format with only 8 significant digits, so there is data loss on 9+ digits.
e.g., the value ‘150 150 567’ is formatted to ‘1.5015056E+008’ so when I call oResult.getLong(), it returns ‘150 150 560’ with the last ‘7’ being rounded to ‘0’.
Is there a way to turn off the scientific format of numbers upon execution of a prepared statement or somehow force it to change the datatype of column to string/varchar?
Or maybe a way other than PreparedStatement to get values from the SQL query to DB via connection?