Re: Encoding and result string length

From: Richard Huxton <dev(at)archonet(dot)com>
To: "kumar" <sgnerd(at)yahoo(dot)com(dot)sg>, "pgsql" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Encoding and result string length
Date: 2004-04-08 11:00:16
Message-ID: 200404081200.16962.dev@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Thursday 08 April 2004 10:32, kumar wrote:
>
> create table encodeco(c1 int4, c2 int4);
> insert into encodeco values(10000, 20000);
> select * from encodeco;
>
> So I want to encode the data while selecting.
> select encode(c1,'base64') from encodeco;

> So i tried
> select encode('c1','base64') from encodeco;

Not quite:
SELECT encode(c1::text, 'base64') FROM encodeco;
or
SELECT encode(CAST(c1 AS text), 'base64') FROM encodeco;

> Also is it possible to get the encoded values with only 2 charactors,
> irrespective of the values of c1 ranging from 100 to 10 million

You could write such a coding so long as you don't mind having ten-thousand
characters in your character-set. Of course, character does not equal byte
like this, but that's true in the various unicode systems anyway.

--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jeff Boes 2004-04-08 19:55:33 SQL challenge--top 10 for each key value?
Previous Message kumar 2004-04-08 09:32:07 Encoding and result string length