Skip site navigation (1) Skip section navigation (2)

cast type bytea to double precision

From: Amila Jayasooriya <amilajayasooriya(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: cast type bytea to double precision
Date: 2012-02-17 07:10:44
Message-ID: CACqosVSfPRdtRbVJJHdQePY0EbDnZS7cnGbgCwo9bfpUVcq8xA@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-sql
HI All,

I have a database column which type is bytea. It contains floats converted
as byte array (4 bytes per one float) and encoding is Escape. I would be
able to get corresponding bytea string using substring function.

My question is how can I convert bytea string to float inside a SQL
function. Earlier I converted to float in C# side. I used
dataReader.getByte method to retrieve bytes and then Converted to float
using BitConverter.ToSingle (.Net build in class) method.

Now I can't use intermediate component as Npqsql driver. I want SQL to
directly convert bytea into floats and return the corresponding number when
execute a query from 3rd party application.

Thanks and Regards
 Amila Jayasooriya

Responses

pgsql-sql by date

Next:From: Amila JayasooriyaDate: 2012-02-17 07:19:15
Subject: cast type bytea to double precision
Previous:From: David JohnstonDate: 2012-02-17 01:33:16
Subject: Re: Window function frame clause

pgsql-general by date

Next:From: Amila JayasooriyaDate: 2012-02-17 07:19:15
Subject: cast type bytea to double precision
Previous:From: John R PierceDate: 2012-02-17 06:38:41
Subject: Re: running multiple versions

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group