Write a PL/SQL block to swap the values of two variables. Print variables before and after swapping.

What will be an ideal response?

```
SQL> SET VERIFY OFF
SQL> DECLARE
2 num1 NUMBER(2) := &s_num1;
3 num2 NUMBER(2) := &s_num2;
4 temp NUMBER(2);
5 BEGIN
6 DBMS_OUTPUT.PUT_LINE ('num1=' || num1 || ' and num2=' || num2);
7 temp := num1;
8 num1 := num2;
9 num2 := temp;
10 DBMS_OUTPUT.PUT (‘After swap,’);
11 DBMS_OUTPUT.PUT_LINE ('num1=' || num1 || ' and num2=' || num2);
12 END;
13 /
Enter value for s_num1: 5
Enter value for s_num2: 10
num1=5 and num2=10
After swap, num1=10 and num2=5

PL/SQL procedure successfully completed.
```

Computer Science & Information Technology

You might also like to view...

Consider the following statements: string str1 = "ABCDEFGHIJKLM";string str2; After the statement str2 = str1.substr(1,4); executes, the value of str2 is "____".

A. ABCD B. BCDE C. BCD D. CDE

Computer Science & Information Technology

This type of port has a number in the 1024 to 49151 range.

A. well-known port B. private port C. dynamic port D. registered port

Computer Science & Information Technology