• 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 SQL : Script To Convert Hexadecimal Input Into a Decimal Value
  2. Oracle Interview Questions : Recovery catalog for RMAN backup
  3. How to Recover From Lost or Missing Database Parameter Files (PFILE or SPFILE)
  4. Oracle RAC: How to modify private hostname, Private network IP & MTU
  5. Stored Procedures and Functions in PL/SQL
  6. Configuring Data Guard in Oracle Cloud Infrastructure (OCI)
  7. How to Enable or Disable Veritas ODM for Oracle database 12.1.0.2, 18c and 19c
  8. Basics of Materialized Views in Oracle
  9. ORA-19554: error allocating device, device type: SBT_TAPE, device name:
  10. How to Disable Oracle Net Tracing on a Server Process without Stopping the Process

You May Also Like

Primary Sidebar

Recent Posts

  • powertop Command Examples in Linux
  • powertop: command not found
  • powerstat: command not found
  • powerstat Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright