Update in SQL

295 pts.
Tags:
Flat files
SQL error messages
SQL/400
UPDATE statement
I have a flat file which I want to update starting from position 2 to 4. I used below UPDATE statement: UPDATE FLAT_FILE SET SUBSTR(FLAT_FILE,2,2)= 'AA' WHERE SUBSTR(FLAT_FILE,1,2) = 'HH' The above SQL Query is throwing an error SQL0104 for missing token. Can anybody suggest me on the above. Thank You.

Answer Wiki

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

You can’t have a function on the left side of an update, it must be the entire column. Try this:

UPDATE FLAT_FILE
SET FLAT_FILE = SUBSTR(FLAT_FILE,1,1)|| ‘AA’||SUBSTR(FLAT_FILE,4)
WHERE SUBSTR(FLAT_FILE,1,2) = ‘HH’

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.

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.

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

Following

Share this item with your network: