Pages

Friday, August 30, 2013

Widgets

SUBSTR to replace

SUBSTR can also to used to replace values of a string. In the below example the variable ID, where the first two characters can replaced by XX, with the help of the SUBSTR function

LAST      NAME    ID
Barczak  George  CP436
Adams   Linda     LA543
Preiss    Gloria    AU942
To change the first two letters of the  ID to "XX", use the SUBSTR function on the left side of the assignment statement:
substr(employee_id,1,2)='DA';
Result:
LAST       NAME     ID
Barczak   George   XX436
Adams    Linda      XX543
Preiss     Gloria     XX942

No comments:

Post a Comment