-1

I have insert query like below

INSERT INTO PUBLIC.STAFF(NAME, PICTURE,EMAIL) VALUES
('samplePic', X'89504e470d0a1a0a0000000d4', '[email protected]'); 

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', '[email protected]'); 
2

2 Answers 2

0

Try to use replace method like this:

 String query = "INSERT INTO PUBLIC.STAFF(NAME, PICTURE,EMAIL) VALUES('samplePic', X'89504e470d0a1a0a0000000d4', '[email protected]')";
 query = query.replace("X'89504e47", "'\\x89504e47");

Output:

 INSERT INTO PUBLIC.STAFF(NAME, PICTURE,EMAIL) VALUES('samplePic', '\x89504e470d0a1a0a0000000d4', '[email protected]')
Sign up to request clarification or add additional context in comments.

1 Comment

But we have to use regular expression for getting exact binary string match
-4

you should write as below.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.