Database package and numeric type

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Database package and numeric type

jfr2020
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Database package and numeric type

Olaf Till-2
Hello,

On Tue, Jun 23, 2020 at 01:24:05PM +0000, Jean-Felix Riou wrote:
>     Hello,
> I am trying to retrieve data of numeric type from a postgres
> database. I use the octave database package 2.4.4. However it throws
> an error when executing a simple select query:

I like these reports based on the scheme "even a simple command with
this package doesn't work"...

> “no converter found
> for element oid 1700”.I guess that the numeric type is not supported
> by the database package.

Indeed it currently isn't supported. I've taken a look at the binary
transmission format of "numeric" in postgresql -- implementing a
converter shouldn't be a monstrous task, but also won't be a matter of
a few minutes.

> I cannot change the database itself. Is there a way I can tell
> octave/database to automatically convert numeric into float8 for
> example? So far the workaround I have found is to add a CAST for
> every numeric field in the query itself but that is painful when
> there are many numeric fields....  Thanks.

It's not only painful, but generally lossy. For the same reason, there
won't be an automatic conversion to a floating point type by the
database package. Once the converter is implemented, it probably will
convert "numeric" to an Octave string. For calculations within Octave,
you'll have to convert this string manually (but simply using
"str2num" will generally be lossy again). Maybe the symbolic package
will be useful for doing this without loss.

Olaf

--
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net



signature.asc (849 bytes) Download Attachment