0

I have a table with three columns. Column1 is id. Column2 is filename. Column3 is location. I need to write a query that will take all files with filename = X and will replace part of the string for 'location' lets say location = '/home/AAA/bin' and it will replace it with '/home/BBB/bin'. The start of location is always the same but the end is not always the same. I mean it will always start with /home/AAA/ but the end of the location is different for every file - /bin/ could be /somethingelse/.

1
  • What did you try so far? What problems did you encounter? Commented Jun 6, 2012 at 18:17

1 Answer 1

1

You need to use this Postgres function

overlay(string placing string from int [for int]) 
ex: overlay('Txxxxas' placing 'hom' from 2 for 4)

Your situation involves the select statement having the following:

overlay(location placing '/home/BBB' from 1 for 9)

You can get more information from here.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.