You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@empire-db.apache.org by Frank Lupo <fr...@email.it> on 2009/07/02 17:39:27 UTC

reverse function in postgresql

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

Re: Nexus repository access

Posted by Francis De Brabandere <fr...@gmail.com>.
I added a ping comment to that Jira issue
https://issues.apache.org/jira/browse/INFRA-2118

On Mon, Jul 6, 2009 at 10:21 PM, Rainer Döbele<do...@esteam.de> wrote:
> Hi Franics,
>
> I think we should wait with the release until we have the Nexus repository access.
>
> Have you not sent a ping to Brian Fox yet?
> Won't do any harm (I hope).
>
> Regards
> Rainer
>
> Francis De Brabandere wrote:
>> Re: Nexus repository access
>>
>> Should I comment on that issue as a ping or is that against the Apache
>> spirit ;-) We can"t start our release before this is taken care of.
>>
>> Francis
>>
>> On Fri, Jul 3, 2009 at 11:09 AM, Francis De
>> Brabandere<fr...@gmail.com> wrote:
>> > according to: https://issues.apache.org/jira/browse/INFRA-2118
>> >
>> > ASAP
>> >
>> > but maybe a ping might help indeed
>> >
>> > On Fri, Jul 3, 2009 at 10:54 AM, Martijn
>> > Dashorst<ma...@gmail.com> wrote:
>> >> On Fri, Jul 3, 2009 at 8:54 AM, Rainer Döbele<do...@esteam.de>
>> wrote:
>> >>> The status of Empire-db for Nexus is still on "Open". Hadoop has
>> been on status "In Progress" for quite some time.
>> >>>
>> >>> Has anyone an idea of how long this could take?
>> >>
>> >> Not a clue.
>> >>
>> >> Ping infrastructure maybe.
>> >>
>> >> Martijn
>> >>
>> >
>> >
>> >
>> > --
>> > http://www.somatik.be
>> > Microsoft gives you windows, Linux gives you the whole house.
>> >
>>
>>
>>
>> --
>> http://www.somatik.be
>> Microsoft gives you windows, Linux gives you the whole house.
>



-- 
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.

re: Nexus repository access

Posted by Rainer Döbele <do...@esteam.de>.
Hi Franics,

I think we should wait with the release until we have the Nexus repository access.

Have you not sent a ping to Brian Fox yet?
Won't do any harm (I hope).

Regards
Rainer

Francis De Brabandere wrote:
> Re: Nexus repository access
> 
> Should I comment on that issue as a ping or is that against the Apache
> spirit ;-) We can"t start our release before this is taken care of.
> 
> Francis
> 
> On Fri, Jul 3, 2009 at 11:09 AM, Francis De
> Brabandere<fr...@gmail.com> wrote:
> > according to: https://issues.apache.org/jira/browse/INFRA-2118
> >
> > ASAP
> >
> > but maybe a ping might help indeed
> >
> > On Fri, Jul 3, 2009 at 10:54 AM, Martijn
> > Dashorst<ma...@gmail.com> wrote:
> >> On Fri, Jul 3, 2009 at 8:54 AM, Rainer Döbele<do...@esteam.de>
> wrote:
> >>> The status of Empire-db for Nexus is still on "Open". Hadoop has
> been on status "In Progress" for quite some time.
> >>>
> >>> Has anyone an idea of how long this could take?
> >>
> >> Not a clue.
> >>
> >> Ping infrastructure maybe.
> >>
> >> Martijn
> >>
> >
> >
> >
> > --
> > http://www.somatik.be
> > Microsoft gives you windows, Linux gives you the whole house.
> >
> 
> 
> 
> --
> http://www.somatik.be
> Microsoft gives you windows, Linux gives you the whole house.

Re: Nexus repository access

Posted by Francis De Brabandere <fr...@gmail.com>.
Should I comment on that issue as a ping or is that against the Apache
spirit ;-) We can"t start our release before this is taken care of.

Francis

On Fri, Jul 3, 2009 at 11:09 AM, Francis De
Brabandere<fr...@gmail.com> wrote:
> according to: https://issues.apache.org/jira/browse/INFRA-2118
>
> ASAP
>
> but maybe a ping might help indeed
>
> On Fri, Jul 3, 2009 at 10:54 AM, Martijn
> Dashorst<ma...@gmail.com> wrote:
>> On Fri, Jul 3, 2009 at 8:54 AM, Rainer Döbele<do...@esteam.de> wrote:
>>> The status of Empire-db for Nexus is still on "Open". Hadoop has been on status "In Progress" for quite some time.
>>>
>>> Has anyone an idea of how long this could take?
>>
>> Not a clue.
>>
>> Ping infrastructure maybe.
>>
>> Martijn
>>
>
>
>
> --
> http://www.somatik.be
> Microsoft gives you windows, Linux gives you the whole house.
>



-- 
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.

Re: Nexus repository access

Posted by Francis De Brabandere <fr...@gmail.com>.
according to: https://issues.apache.org/jira/browse/INFRA-2118

ASAP

but maybe a ping might help indeed

On Fri, Jul 3, 2009 at 10:54 AM, Martijn
Dashorst<ma...@gmail.com> wrote:
> On Fri, Jul 3, 2009 at 8:54 AM, Rainer Döbele<do...@esteam.de> wrote:
>> The status of Empire-db for Nexus is still on "Open". Hadoop has been on status "In Progress" for quite some time.
>>
>> Has anyone an idea of how long this could take?
>
> Not a clue.
>
> Ping infrastructure maybe.
>
> Martijn
>



-- 
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.

Re: Nexus repository access

Posted by Martijn Dashorst <ma...@gmail.com>.
On Fri, Jul 3, 2009 at 8:54 AM, Rainer Döbele<do...@esteam.de> wrote:
> The status of Empire-db for Nexus is still on "Open". Hadoop has been on status "In Progress" for quite some time.
>
> Has anyone an idea of how long this could take?

Not a clue.

Ping infrastructure maybe.

Martijn

Nexus repository access

Posted by Rainer Döbele <do...@esteam.de>.
Francis De Brabandere
> Re: reverse function in postgresql
> 
> no haste, I think we can keep such a change for a later release

+1

> Hope we get access to that nexus soon.

The status of Empire-db for Nexus is still on "Open". Hadoop has been on status "In Progress" for quite some time.

Has anyone an idea of how long this could take?


Rainer

> 
> On Thu, Jul 2, 2009 at 9:34 PM, Rainer Döbele<do...@esteam.de> wrote:
> > Great.
> > I won't be able to do anything about it tonight or tomorrow, but I'll
> keep it on my list.
> >
> > Regards
> > Rainer
> >
> >
> > Francis De Brabandere
> >> Re: reverse function in postgresql
> >>
> >> Yep, got postrgesql running on my other machine so I can actually test
> >> with it
> >>
> >> On Thu, Jul 2, 2009 at 9:21 PM, Rainer Döbele<do...@esteam.de> wrote:
> >> > Francis you are unbelievable. I've just created the issue in JIRA and
> >> two minutes later you've already checked the code in. You must have
> >> been waiting for that all day.
> >> > Thanks a lot for that.
> >> > Apparently you don't have the right to create JIRA issues yourself. I
> >> always thought you had.
> >> > I will see if I am able to give you the right to do so.
> >> >
> >> > As you have probably seen, I have just created another issue for the
> >> reverse function problem.
> >> > I am not yet sure how to deal with this in this case and in general.
> >> > The original idea was to take all common SQL functions and support
> >> them for all database drivers.
> >> > For database specific functions additional functions could be
> >> implemented either on the database driver or on the DBCommand object
> >> that is created through the driver. An example for this is Oracle where
> >> we support the "connect by prior" function with the DBCommandOracle
> >> object.
> >> > What I think we should not do, is to create the function in postgre
> >> without the user's consent, i.e. without him telling us to do so. This
> >> in turn means that we have to put the code Frank suggested in a special
> >> method on the driver and anyone who wishes to use the reverse function
> >> must call this method if the reverse function does not already exist.
> >> >
> >> > I will think about this some more and give you my opinion how to deal
> >> with this.
> >> > However one problem for me is, that I don't have any postgre SQL
> >> database running here and I cannot test it.
> >> > Francis have you?
> >> >
> >> > Rainer
> >> >
> >> > P.S. @Frank Lupo: Thanks a log Frank for your contributions, they are
> >> very helpful.
> >> >
> >> > Francis De Brabandere wrote:
> >> >> Re: reverse function in postgresql
> >> >>
> >> >> Rainer, what do you think about such workarounds??
> >> >>
> >> >> On Thu, Jul 2, 2009 at 5:39 PM, Frank Lupo<fr...@email.it>
> >> wrote:
> >> >> > 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
> >> >> >
> >> >>
> >> >>
> >> >>
> >> >> --
> >> >> http://www.somatik.be
> >> >> Microsoft gives you windows, Linux gives you the whole house.
> >> >
> >>
> >>
> >>
> >> --
> >> http://www.somatik.be
> >> Microsoft gives you windows, Linux gives you the whole house.
> >
> 
> 
> 
> --
> http://www.somatik.be
> Microsoft gives you windows, Linux gives you the whole house.

Re: reverse function in postgresql

Posted by Francis De Brabandere <fr...@gmail.com>.
no haste, I think we can keep such a change for a later release
Hope we get access to that nexus soon.

On Thu, Jul 2, 2009 at 9:34 PM, Rainer Döbele<do...@esteam.de> wrote:
> Great.
> I won't be able to do anything about it tonight or tomorrow, but I'll keep it on my list.
>
> Regards
> Rainer
>
>
> Francis De Brabandere
>> Re: reverse function in postgresql
>>
>> Yep, got postrgesql running on my other machine so I can actually test
>> with it
>>
>> On Thu, Jul 2, 2009 at 9:21 PM, Rainer Döbele<do...@esteam.de> wrote:
>> > Francis you are unbelievable. I've just created the issue in JIRA and
>> two minutes later you've already checked the code in. You must have
>> been waiting for that all day.
>> > Thanks a lot for that.
>> > Apparently you don't have the right to create JIRA issues yourself. I
>> always thought you had.
>> > I will see if I am able to give you the right to do so.
>> >
>> > As you have probably seen, I have just created another issue for the
>> reverse function problem.
>> > I am not yet sure how to deal with this in this case and in general.
>> > The original idea was to take all common SQL functions and support
>> them for all database drivers.
>> > For database specific functions additional functions could be
>> implemented either on the database driver or on the DBCommand object
>> that is created through the driver. An example for this is Oracle where
>> we support the "connect by prior" function with the DBCommandOracle
>> object.
>> > What I think we should not do, is to create the function in postgre
>> without the user's consent, i.e. without him telling us to do so. This
>> in turn means that we have to put the code Frank suggested in a special
>> method on the driver and anyone who wishes to use the reverse function
>> must call this method if the reverse function does not already exist.
>> >
>> > I will think about this some more and give you my opinion how to deal
>> with this.
>> > However one problem for me is, that I don't have any postgre SQL
>> database running here and I cannot test it.
>> > Francis have you?
>> >
>> > Rainer
>> >
>> > P.S. @Frank Lupo: Thanks a log Frank for your contributions, they are
>> very helpful.
>> >
>> > Francis De Brabandere wrote:
>> >> Re: reverse function in postgresql
>> >>
>> >> Rainer, what do you think about such workarounds??
>> >>
>> >> On Thu, Jul 2, 2009 at 5:39 PM, Frank Lupo<fr...@email.it>
>> wrote:
>> >> > 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
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> http://www.somatik.be
>> >> Microsoft gives you windows, Linux gives you the whole house.
>> >
>>
>>
>>
>> --
>> http://www.somatik.be
>> Microsoft gives you windows, Linux gives you the whole house.
>



-- 
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.

AW: reverse function in postgresql

Posted by Rainer Döbele <do...@esteam.de>.
Great.
I won't be able to do anything about it tonight or tomorrow, but I'll keep it on my list.

Regards
Rainer


Francis De Brabandere
> Re: reverse function in postgresql
> 
> Yep, got postrgesql running on my other machine so I can actually test
> with it
> 
> On Thu, Jul 2, 2009 at 9:21 PM, Rainer Döbele<do...@esteam.de> wrote:
> > Francis you are unbelievable. I've just created the issue in JIRA and
> two minutes later you've already checked the code in. You must have
> been waiting for that all day.
> > Thanks a lot for that.
> > Apparently you don't have the right to create JIRA issues yourself. I
> always thought you had.
> > I will see if I am able to give you the right to do so.
> >
> > As you have probably seen, I have just created another issue for the
> reverse function problem.
> > I am not yet sure how to deal with this in this case and in general.
> > The original idea was to take all common SQL functions and support
> them for all database drivers.
> > For database specific functions additional functions could be
> implemented either on the database driver or on the DBCommand object
> that is created through the driver. An example for this is Oracle where
> we support the "connect by prior" function with the DBCommandOracle
> object.
> > What I think we should not do, is to create the function in postgre
> without the user's consent, i.e. without him telling us to do so. This
> in turn means that we have to put the code Frank suggested in a special
> method on the driver and anyone who wishes to use the reverse function
> must call this method if the reverse function does not already exist.
> >
> > I will think about this some more and give you my opinion how to deal
> with this.
> > However one problem for me is, that I don't have any postgre SQL
> database running here and I cannot test it.
> > Francis have you?
> >
> > Rainer
> >
> > P.S. @Frank Lupo: Thanks a log Frank for your contributions, they are
> very helpful.
> >
> > Francis De Brabandere wrote:
> >> Re: reverse function in postgresql
> >>
> >> Rainer, what do you think about such workarounds??
> >>
> >> On Thu, Jul 2, 2009 at 5:39 PM, Frank Lupo<fr...@email.it>
> wrote:
> >> > 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
> >> >
> >>
> >>
> >>
> >> --
> >> http://www.somatik.be
> >> Microsoft gives you windows, Linux gives you the whole house.
> >
> 
> 
> 
> --
> http://www.somatik.be
> Microsoft gives you windows, Linux gives you the whole house.

Re: reverse function in postgresql

Posted by Francis De Brabandere <fr...@gmail.com>.
Yep, got postrgesql running on my other machine so I can actually test with it

On Thu, Jul 2, 2009 at 9:21 PM, Rainer Döbele<do...@esteam.de> wrote:
> Francis you are unbelievable. I've just created the issue in JIRA and two minutes later you've already checked the code in. You must have been waiting for that all day.
> Thanks a lot for that.
> Apparently you don't have the right to create JIRA issues yourself. I always thought you had.
> I will see if I am able to give you the right to do so.
>
> As you have probably seen, I have just created another issue for the reverse function problem.
> I am not yet sure how to deal with this in this case and in general.
> The original idea was to take all common SQL functions and support them for all database drivers.
> For database specific functions additional functions could be implemented either on the database driver or on the DBCommand object that is created through the driver. An example for this is Oracle where we support the "connect by prior" function with the DBCommandOracle object.
> What I think we should not do, is to create the function in postgre without the user's consent, i.e. without him telling us to do so. This in turn means that we have to put the code Frank suggested in a special method on the driver and anyone who wishes to use the reverse function must call this method if the reverse function does not already exist.
>
> I will think about this some more and give you my opinion how to deal with this.
> However one problem for me is, that I don't have any postgre SQL database running here and I cannot test it.
> Francis have you?
>
> Rainer
>
> P.S. @Frank Lupo: Thanks a log Frank for your contributions, they are very helpful.
>
> Francis De Brabandere wrote:
>> Re: reverse function in postgresql
>>
>> Rainer, what do you think about such workarounds??
>>
>> On Thu, Jul 2, 2009 at 5:39 PM, Frank Lupo<fr...@email.it> wrote:
>> > 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
>> >
>>
>>
>>
>> --
>> http://www.somatik.be
>> Microsoft gives you windows, Linux gives you the whole house.
>



-- 
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.

re: reverse function in postgresql

Posted by Rainer Döbele <do...@esteam.de>.
Francis you are unbelievable. I've just created the issue in JIRA and two minutes later you've already checked the code in. You must have been waiting for that all day.
Thanks a lot for that.
Apparently you don't have the right to create JIRA issues yourself. I always thought you had.
I will see if I am able to give you the right to do so.

As you have probably seen, I have just created another issue for the reverse function problem.
I am not yet sure how to deal with this in this case and in general.
The original idea was to take all common SQL functions and support them for all database drivers.
For database specific functions additional functions could be implemented either on the database driver or on the DBCommand object that is created through the driver. An example for this is Oracle where we support the "connect by prior" function with the DBCommandOracle object.
What I think we should not do, is to create the function in postgre without the user's consent, i.e. without him telling us to do so. This in turn means that we have to put the code Frank suggested in a special method on the driver and anyone who wishes to use the reverse function must call this method if the reverse function does not already exist.

I will think about this some more and give you my opinion how to deal with this.
However one problem for me is, that I don't have any postgre SQL database running here and I cannot test it.
Francis have you?

Rainer

P.S. @Frank Lupo: Thanks a log Frank for your contributions, they are very helpful.

Francis De Brabandere wrote:
> Re: reverse function in postgresql
> 
> Rainer, what do you think about such workarounds??
> 
> On Thu, Jul 2, 2009 at 5:39 PM, Frank Lupo<fr...@email.it> wrote:
> > 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
> >
> 
> 
> 
> --
> http://www.somatik.be
> Microsoft gives you windows, Linux gives you the whole house.

Re: reverse function in postgresql

Posted by Francis De Brabandere <fr...@gmail.com>.
Rainer, what do you think about such workarounds??

On Thu, Jul 2, 2009 at 5:39 PM, Frank Lupo<fr...@email.it> wrote:
> 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
>



-- 
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.