Skip to main content
Solved

help with select statement (replace substr)

  • November 8, 2023
  • 2 replies
  • 64 views

Forum|alt.badge.img+2

I just want to change Character 18, but this goes and changes everything it finds related to Character 18.

 

Org. text  USMCAE*20L080M4D-0000

In the example below, the line of code returns the data as follows : USMCAE*2ELE8EM4D-EEEE

must be : USMCAE*20L080M4D-E000

 

select replace(mx.component_part, substr(mx.component_part, 18, 1), 'E') from prod_structure mx where mx.part_no like '___080___-__-__-___' and mx.component_part like 'US____*___080___-____'

Best answer by Tomas Ruderfelt

Here is an example that only changes character 18 to E:

SUBSTR(mx.component_part,1,17) ||'E' ||SUBSTR(mx.component_part,19,1000)

2 replies

Forum|alt.badge.img+21
  • Superhero (Employee)
  • 500 replies
  • Answer
  • November 8, 2023

Here is an example that only changes character 18 to E:

SUBSTR(mx.component_part,1,17) ||'E' ||SUBSTR(mx.component_part,19,1000)


Forum|alt.badge.img+2
  • Author
  • Do Gooder (Customer)
  • 1 reply
  • November 8, 2023

I never thought of using the concatenation operator. Thank you very much @Tomas Ruderfelt 

Those who have other solutions can also write their solution suggestions to those here.