Re: Convert bytea to Float8

From: Lee Keel <lee(dot)keel(at)uai(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Convert bytea to Float8
Date: 2007-10-15 20:16:40
Message-ID: 76758090F8686C47A44B6FF52514A1D30904DF04@hermes.uai.int
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am sorry to push this issue, but I have clients waiting on a solution for
this. So, does the lack of response mean that I am going to have to find
another approach? Or can this conversion be done in ppgsql\perl?

Thanks in advance,

Lee Keel

_____

From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Lee Keel
Sent: Monday, October 15, 2007 8:33 AM
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] Convert bytea to Float8

Can someone please answer what I hope to be an easy question? I am trying
to convert 8 bytes of a bytea into a float8.

In C# this code looks like:

xCoord = System.BitConverter.ToDouble(arrByte, cnt) ;

But in my plpgsql function, the following gives me an error:

xCoord := substring(arrByte from cnt for 8)::float8;

The error that I get is:

ERROR: 42846: cannot cast type bytea to double precision

I have also tried get_byte, but that seems to only be returning the single
byte and not all 8bytes for the float. Thanks in advance.

Lee Keel

This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender. This
message contains confidential information and is intended only for the
individual named. If you are not the named addressee you should not
disseminate, distribute or copy this e-mail.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2007-10-15 20:26:22 Re: Convert bytea to Float8
Previous Message Benjamin Arai 2007-10-15 19:34:36 Re: Restore v. Running COPY/INDEX seperatly