Rtrim char type column data : RTRIM « Char Functions « Oracle PL / SQL






Rtrim char type column data

 
SQL>
SQL> CREATE TABLE old_item (
  2       item_id   CHAR(20),
  3       item_desc CHAR(25)
  4       );

Table created.

SQL>
SQL> INSERT INTO old_item VALUES('LA-101', 'Can, Small');

1 row created.

SQL> INSERT INTO old_item VALUES('LA-102', 'Can, Large');

1 row created.

SQL> INSERT INTO old_item VALUES('LA-103', 'Bottle, Small');

1 row created.

SQL> INSERT INTO old_item VALUES('LA-104', 'Bottle, Large');

1 row created.

SQL> INSERT INTO old_item VALUES('NY-101', 'Box, Small');

1 row created.

SQL> INSERT INTO old_item VALUES('NY-102', 'Box, Large');

1 row created.

SQL> INSERT INTO old_item VALUES('NY-103', 'Shipping Carton, Small');

1 row created.

SQL> INSERT INTO old_item VALUES('NY-104', 'Shipping Carton, Large');

1 row created.

SQL>
SQL>
SQL> SELECT 'Item  ' ||
  2         RTRIM(item_id) ||
  3         ' is described as a ' ||
  4         RTRIM(item_desc) ||
  5         '.'  "Item Description Sentence"
  6  FROM   old_item;

Item Description Sentence
-----------------------------------------------------------------------
Item  LA-101 is described as a Can, Small.
Item  LA-102 is described as a Can, Large.
Item  LA-103 is described as a Bottle, Small.
Item  LA-104 is described as a Bottle, Large.
Item  NY-101 is described as a Box, Small.
Item  NY-102 is described as a Box, Large.
Item  NY-103 is described as a Shipping Carton, Small.
Item  NY-104 is described as a Shipping Carton, Large.

8 rows selected.

SQL>
SQL> drop table OLD_ITEM;

Table dropped.

SQL>

 








Related examples in the same category

1.Rtrim: removes a set of characters from the right of a string
2.RTRIM function removes trailing characters
3.Use rtim to remove space