function which reverse a given word

Is there any function in vertica which reverse a word? E.g: "vertica" becomes "acitrev"

Comments

  • Navin_CNavin_C Vertica Customer
    Hello Abhishek, For your requirement, I suggest you go with creating a UDx ( user defined extension ) for Reverse String For the above scenario we can do it like this create function reverse(x varchar) return varchar as begin return (substr(x, 10, 1 ) || substr(x, 9, 1 ) || substr(x, 8, 1 ) || substr(x, 7, 1 ) || substr(x, 6, 1 ) || substr(x, 5, 1 ) || substr(x, 4, 1 ) || substr(x, 3, 1 ) || substr(x, 2, 1 ) || substr(x, 1, 1 )); end; CREATE FUNCTION nnani=> select reverse('Vertica') from dual; reverse --------- acitreV (1 row) This Function is limited to 10 Characters word.
  • Thanks Navin !! Actually I was eager to know whether there is any "reverse" function as we have in oracle. It seems the answer is "No". We will have to make a UDx
  • If you do write a UDx, you're more than welcome to submit it to Vertica's CompatLib package (which contains other UDx's based on Oracle functions, but not reverse()): https://github.com/vertica/Vertica-Extension-Packages/tree/master/compatlib_functions

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file