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 function and procedure in pl sql?

702


How do you sort in sql?

774


Why do we need sharding?

730


how many sql dml commands are supported by 'mysql'? : Sql dba

790


Differences between Oracle 9i and 10g (Probably in terms of SQL and PL/SQL)?

3309






How many joins can you have in sql?

687


what are integrity rules?

754


What is rename in sql?

726


What is the purpose of cursors in pl/sql?

798


How many tables can a sql database have?

710


What is trigger point?

732


What are types of exception?

686


Are left and right joins the same?

720


how can we destroy the session, how can we unset the variable of a session? : Sql dba

729


Name some usages of database trigger?

746