Helpful Information
 
 
Category: Oracle Development
Q. about a couple of oracle commands

hi all,
got a couple of 'how to' questions about a couple of oracle commands.

First one is how do u get items in a column that you have produced from a select statement to be aligned to the right.

Second, is it possible to rename an item in a report that you have produced. For example if in the table that you created the report off, there is a column called head size and the values in that column are either S,M,L. but in the report u want those values to appear as Small, Medium,Large.

thanks, waz.

Hi,
(1) You can specify alignment of a column value using SQL*Plus command:
for example in 'emp' table, you want column 'ename' to be appear right justified.

SQL>COLUMN ENAME JUSTIFY RIGHT

(2) DECODE funtion provides IF.... THEN.....ELSE implementation in SELECT statement. For example

SELECT Item#,
Ord_qty,
DECODE(Size,'S', 'Small', 'M',Medium', 'L', 'large'),
FROM Order_detail
/

If you are using Oracle9i then you can also use CASE....WHEN expression.


Regards

BTW, The CASE....WHEN expression is also available in 8.1.6.

Cheers,
Dan