Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8385053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:34:16+00:00 2026-06-09T17:34:16+00:00

How can I reverse a string using Teradata Stored Procedure Language (SPL) ? The

  • 0

How can I reverse a string using Teradata Stored Procedure Language (SPL) ? The requirement was to replicate the SQL-Server replace() function. This could be achieved by writing a corresponding UDF in Teradata but I want to achieve the same using a Procedure.

The procedure could be then used to initialize the variable before its use in the actual statement having reverse().

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:34:17+00:00Added an answer on June 9, 2026 at 5:34 pm

    This can be achieved using he following Stored Procedure.

    The main logic behind it is that in each iteration (number of iterations equal to the length of the string), we concatinate the last alphabet to a variable.

    REPLACE PROCEDURE database.REVERSE_STRING(INOUT STRING VARCHAR(20))
    BEGIN
    --Declare Variables
    DECLARE STRING_LOCAL  VARCHAR(20); -- Local Copy
    DECLARE STRING_LEN VARCHAR(20); -- String Length
    
    --Initialize Variables
    SET STRING_LEN = CHARACTER_LENGTH(STRING); -- Find Out the length of string
    SET STRING_LOCAL = ''; -- Initialize local copy
    
    --Main Loop
    WHILE(STRING_LEN > 0)
    DO
        SET STRING_LOCAL = STRING_LOCAL || SUBSTR(STRING,STRING_LEN,1); -- In each Iteration copy last alphabet and con cat with STRING_LOCAL
        SET STRING_LEN = STRING_LEN - 1; -- Decrease Iterator Value
    END WHILE;
    
    SET STRING = TRIM(STRING_LOCAL); -- Return reversed string
    
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone reverse this handy hash code I'm using? using System.Security.Cryptography; public static string
I am trying to reverse a string in Lua without using the string.reverse() function.
Does anyone know how I can reverse this function to produce the original input
Can I use the reverse geocoding server side, e.g. with a C# or C++?
I was just researching how can I reverse a String. I found a Program
I am trying to reverse a C style string using the following simple program.
Can anyone explain to me how to reverse an integer without using array or
Can COMMON Table expressions be used to avoid having SQL Server perform the following
I was working on writing a small code snippet to reverse a string using
In Python 2.5 I stored data using this code: def GLWriter(file_name, string): import cPickle

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.