Oracle SQL – Trimming a Specific Literal from a Field


I have frequently used the trim command for one purpose or another, but I have not used it to extract a literal out of a field, which I recently used to extract invalid values from a field in SQL.  So, I am providing a sample SQL for Future reference.

SQL Pattern:

  Select trim (‘I’ FROM <<FieldName>>)  AS <<FieldName>>

From <<TableName>>;

Substitution example:

In this example an invalid indicator (‘Y’) is being removed, performing a Null Value Logic (NVL) substitution to an integer compatible value, then the field is converted to an integer.


CAST( NVL(trim (‘Y’ FROM AA.Status_ID) ,’0′)AS                   INT)         AS PACK_SZ

From  Inventory_code_TBL AA;

1 thought on “Oracle SQL – Trimming a Specific Literal from a Field”

Leave a Reply Cancel reply