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?

Answers were Sorted based on User's Feedback



there are 2 variables called x and y ,x contains 1,2 and y contains 3,4 we have to swap the values..

Answer / parivesh sinha

declare
x number:=1;
x1 number:=2;
y number:=3;
y1 number:=4;
begin
x := y1- y;
dbms_output.put_line (x);
x1 := y1+1 - y;
dbms_output.put_line (x1);
y := x +x1;
dbms_output.put_line (y);
y1 := x1+1 +x;
dbms_output.put_line (y1);
end;

Is This Answer Correct ?    0 Yes 4 No

there are 2 variables called x and y ,x contains 1,2 and y contains 3,4 we have to swap the values..

Answer / santhi k

IN ORACLE...

SELECT DECODE(X,X,Y)X,DECODE(Y,Y,X)Y FROM TABLENAME;

Is This Answer Correct ?    0 Yes 6 No

Post New Answer

More SQL PLSQL Interview Questions

I have a package in which a table was used in a procedure and compiled later i have dropped the table used in the package what would be the status of package specification and body

1 Answers   TCS,


What is the difference between inner join and outer join?

0 Answers  


what are myisam tables? : Sql dba

0 Answers  


what is bulk bind

4 Answers   TCS,


Table Student has 3 columns,Student_id,Student_Name & Course_Id. Table Course has 2 columns, Course_Id & Course_Name.Write a query to listdown all the Courses and number of student in each course.

10 Answers   TCS,






How can we Get the Updated Rows? ie, There is 100s of Rows i updated the Rows who have salary 5000. then i want to select the Updated Rows. How can we achieve it?

4 Answers   Fidelity, KCP,


what are the maximum number of rows that can be constructed by inserting rows directly in value list? : Transact sql

0 Answers  


What are schema-level triggers?

0 Answers  


Why stored procedure is faster than query?

0 Answers  


how will you find out the last three records in a table with n no of records and delete them

3 Answers  


How can triggers be used for the table auditing?

0 Answers  


What is cursor explain with example?

0 Answers  


Categories