there are 2 variables called x and y ,x contains 1,2 and y
contains 3,4 we have to swap the values from x to y and y
to x with out using dummy variables and it can be done only
by using a single statement ? how?

Answer Posted / senthil kumar

declare
x number:= 1;
y number:= 3;
begin
x := x + y;
dbms_output.put_line (x); -- output 4;
y := x - y;
dbms_output.put_line (y); -- output 1;
x := x - y;
dbms_output.put_line (x); -- output 3;
end;
/

Now Y got 1 and x got 3 samae way of x = 2, y =4

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is mutating trigger?

572


What are data types in pl sql?

552


What is the difference between clustered and non-clustered indexes?

595


What are sql functions? Describe the different types of sql functions?

548


What is a stored procedure in sql with example?

594






What is the command used to fetch the first 5 characters of a string?

704


Does truncate release storage space?

548


What is snowflake sql?

573


What packages(if any) has oracle provided for use by developers?

5014


What is the use of double ampersand (&&) in sql queries? Give an example

602


Does sql between include endpoints?

550


How many postgresql users are there, worldwide?

569


How to raise user-defined exception with custom sqlerrm ?

674


Does pl/sql support create command?

572


How does pl sql work?

515