Return-Path: Delivered-To: apmail-incubator-empire-db-dev-archive@minotaur.apache.org Received: (qmail 68674 invoked from network); 2 Jul 2009 15:40:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Jul 2009 15:40:23 -0000 Received: (qmail 33828 invoked by uid 500); 2 Jul 2009 15:40:33 -0000 Delivered-To: apmail-incubator-empire-db-dev-archive@incubator.apache.org Received: (qmail 33810 invoked by uid 500); 2 Jul 2009 15:40:33 -0000 Mailing-List: contact empire-db-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: empire-db-dev@incubator.apache.org Delivered-To: mailing list empire-db-dev@incubator.apache.org Received: (qmail 33800 invoked by uid 99); 2 Jul 2009 15:40:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jul 2009 15:40:33 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [212.97.34.18] (HELO smtp-out07.email.it) (212.97.34.18) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Jul 2009 15:40:23 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp-out07.email.it (Postfix) with ESMTP id 7C37154064 for ; Thu, 2 Jul 2009 17:40:01 +0200 (CEST) X-Virus-Scanned: amavisd-new at email.it Received: from smtp-out07.email.it ([127.0.0.1]) by localhost (smtp-out07.email.it [127.0.0.1]) (amavisd-new, port 10024) with LMTP id h7wMNAMj9rnq for ; Thu, 2 Jul 2009 17:40:01 +0200 (CEST) Received: from [10.14.40.7] (unknown [79.135.50.82]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-out07.email.it (Postfix) with ESMTP id 2528D54048 for ; Thu, 2 Jul 2009 17:40:01 +0200 (CEST) Message-ID: <4A4CD4AF.9090607@email.it> Date: Thu, 02 Jul 2009 17:39:27 +0200 From: Frank Lupo User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: empire-db-dev@incubator.apache.org Subject: reverse function in postgresql Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Hi all, in postgreql the reverse function not exist. Is posible create function reverse when connect to db? thanks ===================================================== 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; ===================================================== 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; ===================================================== create or replace function reverse_string(text) returns text as ' DECLARE reversed_string text; incoming alias for $1; BEGIN reversed_string = ''''; for i in reverse char_length(incoming)..1 loop reversed_string = reversed_string || substring(incoming from i for 1); end loop; return reversed_string; END' language plpgsql; -- Caselle da 1GB, trasmetti allegati fino a 3GB e in piu' IMAP, POP3 e SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f Sponsor: Se ci racconti i tuoi gesti d'amore per il tuo cane, Cesar ti premia. Partecipa anche tu! Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=9205&d=2-7