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<[email protected]> 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<[email protected]> 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<[email protected]> > >> 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.
