Links
Home
Oracle DBA Forum
Frequent Oracle Errors
TNS:could not resolve the connect identifier specified
Backtrace message unwound by exceptions
invalid identifier
PL/SQL compilation error
internal error
missing expression
table or view does not exist
end-of-file on communication channel
TNS:listener unknown in connect descriptor
insufficient privileges
PL/SQL: numeric or value error string
TNS:protocol adapter error
ORACLE not available
target host or object does not exist
invalid number
unable to allocate string bytes of shared memory
resource busy and acquire with NOWAIT specified
error occurred at recursive SQL level string
ORACLE initialization or shutdown in progress
archiver error. Connect internal only, until freed
snapshot too old
unable to extend temp segment by string in tablespace
Credential retrieval failed
missing or invalid option
invalid username/password; logon denied
unable to create INITIAL extent for segment
out of process memory when trying to allocate string bytes
shared memory realm does not exist
cannot insert NULL
TNS:unable to connect to destination
remote database not found'>ora-02019
exception encountered: core dump
inconsistent datatypes
no data found
TNS:operation timed out
PL/SQL: could not find program
existing state of packages has been discarded
maximum number of processes exceeded
error signaled in parallel query server
ORACLE instance terminated. Disconnection forced
TNS:packet writer failure
see ORA-12699
missing right parenthesis
name is already used by an existing object
cannot identify/lock data file
invalid file operation
quoted string not properly terminated
update year in date column

update year in date column

2004-03-23       - By Justin Cave (DDBC)

Reply:     <<     11     12     13     14     15     16     17     18  

To get the changed data

SELECT add_months( date_column, -12 * 100 )
FROM table

To update the table, assuming there are no rows that are supposed to be greater than 2090...

UPDATE advdb.custtest_barb
SET crdate = add_months( crdate, -12 * 100 )
WHERE crdate > to_date( '01-01-2090 ', 'DD-MM-YYYY ' )

Justin Cave
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

-- --Original Message-- --
From: oracle-l-bounce@(protected) [mailto:oracle-l-bounce@(protected)] On Behalf Of Barbara Baker
Sent: Tuesday, March 23, 2004 1:01 PM
To: oracle-l@(protected)
Subject: update year in date column


OK, I 'm just going to bite the bullet and claim total ignorance here and see if someone takes pity on me :( (sad face a nice touch, eh?)

Someone has accidently updated 378 records in the customer table. The date changed from 1999 to 2099.
I need to change just the year back to 1999 for these records. (I 'd like to keep the time stamp, if possible. The month and day are correct.) I looked on metalink, google, and asktom. Some nice examples, but not what I really need.

Thought I 'd be clever and subtract 1000 from the date.
This works, but I don 't know how to get it formatted back into a date.

I 'd prefer just sqlplus, but will use pl/sql if necessary.

Here 's what I 've done so far:
(solaris 9 oracle 9.2.0.4)

JServer Release 9.2.0.4.0 - Production

DOC > CUSNO CUSNAME
CRDATE
DOC >-- ---- -- -- ---- ---- ---- ---- ---- ---- --
-- ---- --
DOC > 798489 GILBERT, ROSS
09/16/2099
DOC > 826744 HOEFLER, MATT
10/08/2099
DOC > 795126 FORT, JOETTA
09/08/2099
DOC >*/

SQL >
SQL > ---select to_date(to_char(crdate, 'MM/DD/YYYY '))
from customer where cusnoy8489;
SQL > ---update advdb.custtest_barb
SQL > ---set crdate= to_char(crdate, 'MM/DD/YYYY ')) ---from customer
SQL > where cusnoy8489;
SQL >
SQL > select
to_date(to_char(crdate, 'ddmmyyyy ')-1000), 'MM/DD/YYYY ')
2 from customer where cusnoy8489;
select
to_date(to_char(crdate, 'ddmmyyyy ')-1000), 'MM/DD/YYYY ')

*
ERROR at line 1:
ORA-00923 (See ORA-00923.ora-code.com): FROM keyword not found where expected


SQL >
SQL >
SQL > --- these both work
SQL > select to_char(crdate, 'ddmmyyyy ') from
custtest_barb where cusnoy8489;

TO_CHAR(
-- -----
16092099

SQL > select to_char(crdate, 'ddmmyyyy ') - 1000 from
custtest_barb where cusnoy8489;

TO_CHAR(CRDATE, 'DDMMYYYY ')-1000
-- ---- ---- ---- ---- ---- ---
16091099

Thank for any assistance.

Barb



__ ____ ____ ____ ____ ____ ______
Do you Yahoo!?
Yahoo! Finance Tax Center - File online. File on time.
http://taxes.yahoo.com/filing.html
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe send email to: oracle-l-request@(protected) put 'unsubscribe ' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --


-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------
To unsubscribe send email to: oracle-l-request@(protected)
put 'unsubscribe ' in the subject line.
--
Archives are at http://www.freelists.org/archives/oracle-l/
FAQ is at http://www.freelists.org/help/fom-serve/cache/1.html
-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --