0

I have a table with name "User_Report" with these columns.

ID       Name    City    zip    Report_File
101      AAA     PPP     123     -----
102      BBB     QQQ     345     -----
103      CCC     RRR     567     -----
104      FFF     SSS     789     -----

I added Report_File new column and i need to update this column with Name+".rpt". How i can update Report_File column with corressponding Name column data in a single update statement?

Please send me one example?

Thanks in advance.

2 Answers 2

1

Please try below query. In oracle double pipes (||) are used for concatenation of strings:

Update User_Report
SET Report_File=Name||'.rpt';

OR keyword CONCAT can be used. Refer LINK

Update User_Report
SET Report_File=CONCACT(Name, '.rpt')
Sign up to request clarification or add additional context in comments.

Comments

0

Your report_file column appears to be a calculated value, if it will never deviate, then you might consider a virtual column.

alter table user_report add (report_file varchar(40) as (name||'.rpt'));

This way you never have to worry about keeping it in synch, it will always be in synch if name changes or new values are inserted.

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.