From sgnerd@yahoo.com.sg Thu Nov 27 06:53:29 2003 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0A899D1B448 for ; Thu, 27 Nov 2003 06:53:29 +0000 (GMT) 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 36465-10 for ; Thu, 27 Nov 2003 02:52:59 -0400 (AST) Received: from smtp011.mail.yahoo.com (smtp011.mail.yahoo.com [216.136.173.31]) by svr1.postgresql.org (Postfix) with SMTP id 78E24D1B445 for ; Thu, 27 Nov 2003 02:52:57 -0400 (AST) Received: from ptil-138-190-chn.primus-india.net (HELO IVESIA67) (sgnerd@203.196.190.138 with login) by smtp-v1.mail.vip.sc5.yahoo.com with SMTP; 27 Nov 2003 06:52:56 -0000 Message-ID: <00cb01c3b4b2$c23d9520$7502a8c0@hdsc.com> Reply-To: "Kumar" From: "Kumar" To: "psql" Subject: Equivalent of Reverse() functions Date: Thu, 27 Nov 2003 12:20:24 +0530 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00C8_01C3B4E0.D5B5EED0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.7 tagged_above=0.0 required=5.0 tests=HTML_40_50 X-Spam-Level: X-Archive-Number: 200311/299 X-Sequence-Number: 16114 This is a multi-part message in MIME format. ------=_NextPart_000_00C8_01C3B4E0.D5B5EED0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Dear Friends, I am migrating an SQL Server 2000 database to Postgres 7.3.4 running on RH = Linux 7.2. While migrating I encounter SQL Server REVERSE( ) function, seem= s no such functions at Postgres. Is there a equivalent function available at Postgres? Please shed some light Regards Kumar ------=_NextPart_000_00C8_01C3B4E0.D5B5EED0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Dear Friends,
 
I am migrating an SQL Server 2000 database to Postgres = 7.3.4=20 running on RH Linux 7.2. While migrating I encounter SQL Server REVERSE( )= =20 function, seems no such functions at Postgres.
 
Is there a equivalent function available at Postgres? P= lease=20 shed some light
 
Regards
Kumar

------=_NextPart_000_00C8_01C3B4E0.D5B5EED0-- From mail@joeconway.com Thu Nov 27 07:27:00 2003 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3ACDCD1B473 for ; Thu, 27 Nov 2003 07:27:00 +0000 (GMT) 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 39378-10 for ; Thu, 27 Nov 2003 03:26:32 -0400 (AST) Received: from joeconway.com (66-146-172-86.skyriver.net [66.146.172.86]) by svr1.postgresql.org (Postfix) with ESMTP id 2A5D3D1B480 for ; Thu, 27 Nov 2003 03:26:31 -0400 (AST) Received: from [192.168.5.3] (account jconway HELO joeconway.com) by joeconway.com (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 674256; Wed, 26 Nov 2003 23:24:22 -0800 Message-ID: <3FC5A6B4.70600@joeconway.com> Date: Wed, 26 Nov 2003 23:24:36 -0800 From: Joe Conway User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kumar Cc: psql Subject: Re: Equivalent of Reverse() functions References: <00cb01c3b4b2$c23d9520$7502a8c0@hdsc.com> In-Reply-To: <00cb01c3b4b2$c23d9520$7502a8c0@hdsc.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/300 X-Sequence-Number: 16115 Kumar wrote: > I am migrating an SQL Server 2000 database to Postgres 7.3.4 running > on RH Linux 7.2. While migrating I encounter SQL Server REVERSE( ) > function, seems no such functions at Postgres. > > Is there a equivalent function available at Postgres? Please shed > some light How about: create or replace function reverse(text) returns text as ' return reverse($_[0]); ' language plperl; regression=# select reverse('abcdef'); reverse --------- fedcba (1 row) Joe From greg@turnstep.com Sat Nov 29 17:51:41 2003 X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D3425D1E21C for ; Sat, 29 Nov 2003 17:51:41 +0000 (GMT) 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 34945-10 for ; Sat, 29 Nov 2003 13:51:16 -0400 (AST) Received: from biglumber.com (biglumber.com [207.228.252.42]) by svr1.postgresql.org (Postfix) with SMTP id A81B9D1E216 for ; Sat, 29 Nov 2003 13:51:04 -0400 (AST) Received: (qmail 4145 invoked from network); 29 Nov 2003 17:51:10 -0000 Received: from unknown (HELO localhost) (207.228.252.42) by 0 with SMTP; 29 Nov 2003 17:51:10 -0000 From: greg@turnstep.com To: pgsql-sql@postgresql.org Cc: sgnerd@yahoo.com.sg Cc: sgnerd@yahoo.com.sg Subject: Re: Equivalent of Reverse() functions X-PGP-Key: 2529 DF6A B8F7 9407 E944 45B4 BC9B 9067 1496 4AC8 X-Request-PGP: http://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8 In-Reply-To: <00cb01c3b4b2$c23d9520$7502a8c0@hdsc.com> Date: Sat, 29 Nov 2003 17:51:10 -0000 X-Mailer: JoyMail 1.38 Message-ID: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200311/344 X-Sequence-Number: 16159 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 > I am migrating an SQL Server 2000 database to Postgres 7.3.4 running > on RH Linux 7.2. While migrating I encounter SQL Server REVERSE( ) > function, seems no such functions at Postgres. > > Is there a equivalent function available at Postgres? Please > shed some light No. If you have plperl installed, as somebody already posted, you can take advantage of perl's built in reverse() function. Here is a plpgsql version: CREATE OR REPLACE FUNCTION reverse(TEXT) RETURNS TEXT AS ' DECLARE original ALIAS FOR $1; reversed TEXT := \'\'; onechar VARCHAR; mypos INTEGER; BEGIN SELECT LENGTH(original) INTO mypos; LOOP EXIT WHEN mypos < 1; SELECT substring(original FROM mypos FOR 1) INTO onechar; reversed := reversed || onechar; mypos := mypos -1; END LOOP; RETURN reversed; END ' LANGUAGE plpgsql IMMUTABLE RETURNS NULL ON NULL INPUT; pg=> SELECT reverse('A man, a plan, a canal, Panama'); reverse - -------------------------------- amanap ,lanac a ,nalp a ,nam A - -- Greg Sabino Mullane greg@turnstep.com PGP Key: 0x14964AC8 200311291246 -----BEGIN PGP SIGNATURE----- iD8DBQE/yNwwvJuQZxSWSsgRAnTyAJ9TqV0D3pV4Cv2b0VZfb8TxuvgxKgCeNBN+ OoFWwoD3omlLw+MUxcWZkT0= =JtRf -----END PGP SIGNATURE-----