Oracle SQL – Trimming a Specific Literal from a Field

Oracle Database

Oracle Database

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 a 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;


Reference Links:



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

  1. Pingback: Oracle SQL – Removing Non-Numeric Characters | Scientia Compendium

Comments are closed.