Solved

Update a column

Posted on 2013-06-11
3
355 Views
Last Modified: 2013-06-11
Hi,
I have a column with DATE datatype and has data in it.
Based on this column, I would like to update another column that is of NUMBER datatype.
The data should be updated as follows:

source_column: 01-JAN-2013
target_column: 20130101 (YYYYMMDD format)

Could someone please suggest?

Thanks
0
Comment
Question by:MRPT
  • 2
3 Comments
 
LVL 37

Expert Comment

by:Gerwin Jansen
Comment Utility
Try this:

select to_number(to_char(trunc(source_column),'YYYYMMDD'))
from your_table;

(to see if you get the right values).
0
 
LVL 37

Accepted Solution

by:
Gerwin Jansen earned 500 total points
Comment Utility
And if it looks OK, update like this:

update your_table
set target_column = to_number(to_char(trunc(source_column),'YYYYMMDD'));
0
 

Author Closing Comment

by:MRPT
Comment Utility
Works as wanted, thank you.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now