pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedEncoding and result string length
2+ messages / 2 participants
[nested] [flat]
* Encoding and result string length
@ 2004-04-08 09:32 kumar <sgnerd@yahoo.com.sg>
2004-04-08 11:00 ` Re: Encoding and result string length Richard Huxton <dev@archonet.com>
0 siblings, 1 reply; 2+ messages in thread
From: kumar @ 2004-04-08 09:32 UTC (permalink / raw)
To: pgsql-sql
Dear Friends,
Postgres 7.3.2 on Linux 8
I would like to fetch the datas from a table in a encoded format.
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;
ERROR: Function encode(integer, "unknown") does not exist
Unable to identify a function that satisfies the given argument types
You may need to add explicit typecasts
So i tried
select encode('c1','base64') from encodeco;
I got a result as
1 YzE=
But this is the encoded value for 'c1' and not for the value 10000.
Please shed some light.
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
Thanks
Kumar
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Encoding and result string length
2004-04-08 09:32 Encoding and result string length kumar <sgnerd@yahoo.com.sg>
@ 2004-04-08 11:00 ` Richard Huxton <dev@archonet.com>
0 siblings, 0 replies; 2+ messages in thread
From: Richard Huxton @ 2004-04-08 11:00 UTC (permalink / raw)
To: kumar <sgnerd@yahoo.com.sg>; 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
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2004-04-08 11:00 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-04-08 09:32 Encoding and result string length kumar <sgnerd@yahoo.com.sg>
2004-04-08 11:00 ` Richard Huxton <dev@archonet.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox