help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Database package and numeric type


From: Olaf Till
Subject: Re: Database package and numeric type
Date: Wed, 24 Jun 2020 22:53:45 +0200
User-agent: Mutt/1.10.1 (2018-07-13)

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

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]