• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

PL/SQL: Palindrome Program

by admin

This tutorial demonstrates the Oracle PL/SQL interview question of writing a program for finding whether a number or string is a palindrome number or string.

Here I have written an Oracle PL/SQL procedure which takes input an integer or a string which is to be identified for palindrome number or string.

CREATE OR REPLACE PROCEDURE P_CHECK_PALINDROME (P_STR VARCHAR2)
IS
  P_REV_STR VARCHAR2(30);
BEGIN
  FOR I IN REVERSE 1 .. LENGTH(P_STR)
  LOOP
    P_REV_STR := P_REV_STR || SUBSTR(P_STR,I,1);
  END LOOP;
  DBMS_OUTPUT.PUT_LINE('P_REV_STR '||P_REV_STR );
  IF P_STR = P_REV_STR THEN
    DBMS_OUTPUT.PUT_LINE('PALINDROME' );
  ELSE
    DBMS_OUTPUT.PUT_LINE('NOT A PALINDROME' );
  END IF;
END;
/

The procedure can be executed as follows:

SET SERVEROUTPUT ON;
EXEC P_CHECK_PALINDROME ('PLSQL');

Filed Under: oracle

Some more articles you might also be interested in …

  1. Oracle Multitenant: How to Create CDB and PDB
  2. New Connections to the Database lead to ORA-12518 or TNS-12518
  3. Oracle Database Server Architecture: Overview
  4. Oracle Grid 12c: Read Only Instances on Leaf Nodes
  5. How to backup and delete archivelogs older than # number of days
  6. Common Init.ora Parameters and Unix, Linux Kernel Parameters and Relationship Between Them
  7. JDeveloper Interview Questions
  8. Oracle Database : Performing Incomplete Recovery from a missing archivelog file (Change-Based, Cancel-Based, Time-Based)
  9. Unable to export realm protected table using data pump
  10. How to Extend ocfs2 Filesystem with tunefs.ocfs2 Command (Whole device used without partitions)

You May Also Like

Primary Sidebar

Recent Posts

  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found
  • macof: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright