In this section, we will see how to check if a number is a palindrome using PL/SQL. In PL/SQL code, certain groups of commands are arranged within blocks of related statement declarations.
A number is a palindrome if it is the same as its opposite. Consider the number 12321, which is a palindrome, but 12345 is not a palindrome.
DECLARE n number; m number; temp number:=0; rem number; BEGIN n :=12321; m :=n; while n>0 loop rem := mod(n,10); temp := (temp*10)+rem; n := trunc(n/10); end loop; if m = temp then dbms_output.put_line('Palindrome'); else dbms_output.put_line('Not Palindrome'); end if; END;
Palindrome
The above is the detailed content of Check if a number in PL/SQL is a palindrome. For more information, please follow other related articles on the PHP Chinese website!