top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to write a query to find the weather string is Palindrome or not?

+3 votes
571 views
How to write a query to find the weather string is Palindrome or not?
posted Sep 19, 2014 by Archana

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
 
Best answer

DECLARE
lc_str1 VARCHAR2(10) := '&S';
lc_str2 VARCHAR2(10);
ln_n NUMBER;
BEGIN
ln_n := LENGTH(lc_str1);
-- DBMS_OUTPUT.PUT_LINE(ln_n);
FOR i IN REVERSE 1 .. ln_n LOOP
lc_str2 := lc_str2 || SUBSTR(lc_str1,i,1);
-- DBMS_OUTPUT.PUT_LINE(lc_str2);
END LOOP;
IF lc_str1 = lc_str2 THEN
DBMS_OUTPUT.PUT_LINE('Palindrome');
ELSE
DBMS_OUTPUT.PUT_LINE('Not Palindrome');
END IF;
END;

Input:
ARUN

Output:
Not Palindrome

Input:
MOM

Output:
Palindrome

answer Sep 19, 2014 by Arun Gowda
Similar Questions
+2 votes

suppose if i give '12345'

output should be:

1
12
123
1234
12345
1234
123
12
1

0 votes

Display the records between two range I know the nvl function only allows the same data type(ie. number or char or date Nvl(comm, 0)), if commission is null then the text “Not Applicable” want to display, instead of blank space. How do I write the query?

...