From sgnerd@yahoo.com.sg Thu Apr 8 09:31:43 2004 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E3783D1BAEA for ; Thu, 8 Apr 2004 06:31:43 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 49384-05 for ; Thu, 8 Apr 2004 06:31:42 -0300 (ADT) Received: from chn-dns.primus-india.net (chn-dns.primus-india.net [203.196.153.7]) by svr1.postgresql.org (Postfix) with ESMTP id 5B454D1D096 for ; Thu, 8 Apr 2004 06:31:39 -0300 (ADT) Received: from ivesia67 (ptil-138-190-chn.primus-india.net [203.196.190.138] (may be forged)) by chn-dns.primus-india.net (8.12.8/8.12.8) with SMTP id i388VpJk000922 for ; Thu, 8 Apr 2004 14:01:54 +0530 Message-ID: <025001c41d4c$5db0bbc0$7502a8c0@hdsc.com> From: "kumar" To: "pgsql" Subject: Encoding and result string length Date: Thu, 8 Apr 2004 15:02:07 +0530 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_024D_01C41D7A.75FC4860" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/65 X-Sequence-Number: 17440 This is a multi-part message in MIME format. ------=_NextPart_000_024D_01C41D7A.75FC4860 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Dear Friends, Postgres 7.3.2 on Linux 8 I would like to fetch the datas from a table in a encoded format.=20 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; =20=20=20=20 I got a result as 1 YzE=3D But this is the encoded value for 'c1' and not for the value 10000.=20 Please shed some light. Also is it possible to get the encoded values with only 2 charactors, irres= pective of the values of c1 ranging from 100 to 10 million Thanks Kumar ------=_NextPart_000_024D_01C41D7A.75FC4860 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Dear Friends,
 
Postgres 7.3.2 on Linux 8
 
I would like to fetch the datas from a tab= le in a=20 encoded format.
 
create table encodeco(c1 int4, c2 int4);insert=20 into encodeco values(10000, 20000);
select * from encodeco;
 
So I want to encode the data while=20 selecting.
select encode(c1,'base64') from=20 encodeco;

ERROR:  Function encode(integer, "unknown") does not=20 exist
 Unable to identify a function that satisfies the given argum= ent=20 types
 You may need to add explicit typecasts
 
So i  tried
    select encode('c1','bas= e64')=20 from encodeco;
   
I got a result as
    1   &nbs= p;=20 YzE=3D
 
But this is the encoded value for 'c1' and= not for=20 the value 10000.
 
Please shed some light.
 
Also is it possible to get the encoded val= ues with=20 only 2 charactors, irrespective of the values of c1 ranging from 100 to 10= =20 million
 
Thanks
Kumar
 
------=_NextPart_000_024D_01C41D7A.75FC4860-- From dev@archonet.com Thu Apr 8 11:00:33 2004 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 602CAD1D09D for ; Thu, 8 Apr 2004 08:00:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 75913-07 for ; Thu, 8 Apr 2004 08:00:32 -0300 (ADT) Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net [194.217.242.92]) by svr1.postgresql.org (Postfix) with ESMTP id 09154D1D08A for ; Thu, 8 Apr 2004 08:00:28 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-34.mail.demon.net with esmtp (Exim 3.35 #1) id 1BBXGn-000EVT-0Y; Thu, 08 Apr 2004 12:00:30 +0100 Received: by mainbox.archonet.com (Postfix, from userid 529) id ECE431644A; Thu, 8 Apr 2004 12:00:28 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 004051644E; Thu, 8 Apr 2004 12:00:18 +0100 (BST) From: Richard Huxton To: "kumar" , "pgsql" Subject: Re: Encoding and result string length Date: Thu, 8 Apr 2004 12:00:16 +0100 User-Agent: KMail/1.5 References: <025001c41d4c$5db0bbc0$7502a8c0@hdsc.com> In-Reply-To: <025001c41d4c$5db0bbc0$7502a8c0@hdsc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200404081200.16962.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200404/66 X-Sequence-Number: 17441 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