-1

I have insert query like below

INSERT INTO PUBLIC.STAFF(NAME, PICTURE,EMAIL) VALUES
('samplePic', X'89504e470d0a1a0a0000000d4', 'some@domain.com'); 

How to modify above Picture attribute string value (X'89504e47 to \x89504e47) and final Query is will be like.

 INSERT INTO PUBLIC.STAFF(NAME, PICTURE,EMAIL) VALUES
    ('samplePic', '\x89504e470d0a1a0a0000000d4', 'some@domain.com'); 
Madhava
  • 77
  • 2
  • 9
  • Possible duplicate of http://stackoverflow.com/questions/1144783/replacing-all-occurrences-of-a-string-in-javascript – Anoop LL Feb 22 '16 at 06:36
  • Possible duplicate of [String replace in Java](http://stackoverflow.com/questions/1949988/string-replace-in-java) – Anoop LL Feb 22 '16 at 06:37

2 Answers2

0

Try to use replace method like this:

 String query = "INSERT INTO PUBLIC.STAFF(NAME, PICTURE,EMAIL) VALUES('samplePic', X'89504e470d0a1a0a0000000d4', 'some@domain.com')";
 query = query.replace("X'89504e47", "'\\x89504e47");

Output:

 INSERT INTO PUBLIC.STAFF(NAME, PICTURE,EMAIL) VALUES('samplePic', '\x89504e470d0a1a0a0000000d4', 'some@domain.com')
Abdelhak
  • 8,299
  • 4
  • 22
  • 36
-4

you should write as below.

UPDATE PUBLIC.STAFF SET PICTURE ='x89504e47' where NAME ='samplePic';

ManthanB
  • 404
  • 2
  • 5
  • 21