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 range partitioning?

522


How do you use a while loop in pl sql?

539


What does the base_object_type column shows in the user.triggers data dictionary view?

574


how to use in conditions? : Sql dba

514


How to find 3rd highest salary of an employee from the employee table in sql?

567






What is dml and ddl?

525


Explain the difference between cursor declared in procedures and cursors declared in the package specification?

579


Is hadoop a nosql?

574


What is a primary key example?

515


What are sql data types?

548


Mention what is the function that is used to transfer a pl/sql table log to a database table?

486


What happens when a trigger is associated to a view?

503


How to get unique records from a table?

523


What are the two types of cursors in pl sql?

542


Why having clause is used in sql?

542