Using SUBSTR with interactive SQL

200 pts.
Tags:
AS/400
SQL
I am trying to change part of a field using the substring command in interactive SQL. To do this I entered the following:

UPDATE LIBRARY/FILE_NAME SET SUBSTR(FIELD_NAME1,194,4) = 'XXXXX' WHERE FIELD_NAME2 = 99999 


I get the error token ( was not valid. Valid tokens: = .' Obviously there is a syntax error but O cannot figure it out.

Answer Wiki

Thanks. We'll let you know when a new response is added.

Unless something has changed SUBSTR cannot be used as the target of set. It can however be used as part of the expression setting the variable. Try:

UPDATE LIBRARY/FILE_NAME SET FIELD_NAME1 = SUBSTR(FIELD_NAME1,1,193) || 'XXXX' || SUBSTR(FIELD_NAME1,198) WHERE FIELD_NAME2 = 99999

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following