Swap two numbers in PL/SQL Last Updated : 17 May, 2018 Comments Improve Suggest changes Like Article Like Report In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Basic structure of pl/sql block declare -- declare all the variables begin -- for start block -- make a program here end -- for end block You have given two numbers num1 and num2 the your task is to swap the value of given numbers. Examples: Input : num1 = 1000 num2 = 2000 Output : num1 = 2000 num2 = 1000 Input : num1 = 40 num2 = 20 Output : num1 = 20 num2 = 40 SQL declare -- declare variable num1, num2 -- and temp of datatype number num1 number; num2 number; temp number; begin num1:=1000; num2:=2000; -- print result before swapping dbms_output.put_line('before'); dbms_output.put_line('num1 = '|| num1 ||' num2 = '|| num2); -- swapping of numbers num1 and num2 temp := num1; num1 := num2; num2 := temp; -- print result after swapping dbms_output.put_line('after'); dbms_output.put_line('num1 = '|| num1 ||' num2 = '|| num2); end; Output: before num1 = 1000 num2 = 2000 after num1 = 2000 num2 = 1000 Comment More infoAdvertise with us Next Article Sum Of Two Numbers in PL/SQL V vt_m Follow Improve Article Tags : Misc SQL SQL-PL/SQL Practice Tags : Misc Similar Reads Sum Of Two Numbers in PL/SQL Prerequisite - PL/SQL introductionIn PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Here, first, we take three variables x, y, and z and ass 2 min read GCD of two numbers in PL/SQL Prerequisite - PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Given two numbers and task is to find the GCD (Greatest 1 min read GCD of two numbers in PL/SQL Prerequisite - PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Given two numbers and task is to find the GCD (Greatest 1 min read Swap two numbers in PL/SQL without using temp In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Given two numbers num1 and num2 and the task is to swap the value of given numbers. Exampl 2 min read Swap two numbers in PL/SQL without using temp In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Given two numbers num1 and num2 and the task is to swap the value of given numbers. Exampl 2 min read Prime number in PL/SQL Prerequisite â PL/SQL introductionA prime number is a whole number greater than 1, which is only divisible by 1 and itself. First few prime numbers are : 2 3 5 7 11 13 17 19 23 â¦..In PL/SQL code groups of commands are arranged within a block. A block group-related declarations or statements. In decl 1 min read Like