Sunday, April 27, 2014

Swap values of two variables in Oracle SQL

Swapping values of two variables is bit different in oracle SQL then other traditional programming languages .

Here you don't need  to use temporary variable to swap two variables .

Let's say, we want to swap values of two variable called attribute7 and attribute8 of po_vendors table for vendor_id=1000.

We can accomplish above requirement by using below DML statement .

update po_vendors set attribute7=attribute8,attribute8=attribute7 where vendor_id=1000;


No comments:

Post a Comment