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