Hello,
I am trying to update some varchar2 fields, which are storing dates. I
am trying to set a 'to date' with the next minumum from date i.e
from date | to date
01/01/1901 01/01/1902
01/01/1902 01/01/1903
01/01/1903 etc......
I have got a bit lost in creating my update statement, but cannot
understand why I am geting the following error message:-
ora-01847 day of month must be between 1 and last day of month.
The sql is:-
update emp_add_info_values_tab a
set free_column10 = (select b.free_column9
from emp_add_info_values_tab b
where a.add_info_type = 'B MED INS'
and a.free_column4 not in ('N','W')
and a.emp_no = b.emp_no
and b.add_info_type = 'B MED INS'
and to_date(b.free_column9,'DD/MM/RR') =
(select min(to_date(c.free_column9,'DD/MM/RR')) from
emp_add_info_values_tab c
where c.add_info_type = 'B MED INS'
and c.free_column4 not in ('N','W')
and a.emp_no = c.emp_no
and to_date(c.free_column9,'DD/MM/RR') >
to_date(a.free_column9,'DD/MM/RR')))
where exists(select b.free_column9
from emp_add_info_values_tab b
where a.add_info_type = 'B MED INS'
and a.free_column4 not in ('N','W')
and a.emp_no = b.emp_no
and b.add_info_type = 'B MED INS'
and to_date(b.free_column9,'DD/MM/RR') =
(select min(to_date(c.free_column9,'DD/MM/RR')) from
emp_add_info_values_tab c
where c.add_info_type = 'B MED INS'
and c.free_column4 not in ('N','W')
and a.emp_no = c.emp_no
and to_date(c.free_column9,'DD/MM/RR') >
to_date(a.free_column9,'DD/MM/RR')))
Any help would be greatly appreciated...
Cheers,
Simon 6 8583
Hi There,
There is no issue in UPDATE statement but the data must incorrect
stored in the table. Since you are using VARCHAR2 columna and hence it
would allow you to store the first 2 character of date greater than
31. sm********@hotmail.com (Simon) wrote in message news:<c0**************************@posting.google. com>... Hello,
I am trying to update some varchar2 fields, which are storing dates. I am trying to set a 'to date' with the next minumum from date i.e
from date | to date 01/01/1901 01/01/1902 01/01/1902 01/01/1903 01/01/1903 etc......
I have got a bit lost in creating my update statement, but cannot understand why I am geting the following error message:-
ora-01847 day of month must be between 1 and last day of month.
The sql is:-
update emp_add_info_values_tab a set free_column10 = (select b.free_column9 from emp_add_info_values_tab b where a.add_info_type = 'B MED INS' and a.free_column4 not in ('N','W') and a.emp_no = b.emp_no and b.add_info_type = 'B MED INS' and to_date(b.free_column9,'DD/MM/RR') = (select min(to_date(c.free_column9,'DD/MM/RR')) from emp_add_info_values_tab c where c.add_info_type = 'B MED INS' and c.free_column4 not in ('N','W') and a.emp_no = c.emp_no and to_date(c.free_column9,'DD/MM/RR') > to_date(a.free_column9,'DD/MM/RR'))) where exists(select b.free_column9 from emp_add_info_values_tab b where a.add_info_type = 'B MED INS' and a.free_column4 not in ('N','W') and a.emp_no = b.emp_no and b.add_info_type = 'B MED INS' and to_date(b.free_column9,'DD/MM/RR') = (select min(to_date(c.free_column9,'DD/MM/RR')) from emp_add_info_values_tab c where c.add_info_type = 'B MED INS' and c.free_column4 not in ('N','W') and a.emp_no = c.emp_no and to_date(c.free_column9,'DD/MM/RR') > to_date(a.free_column9,'DD/MM/RR')))
Any help would be greatly appreciated...
Cheers,
Simon
not sure if I totally understand your answer...I have looked at the
data in the table and cannot see any immediate problems. I have done a
length on the fields
select distinct length(b.free_column9)
from emp_add_info_values_tab b
where b.add_info_type = 'B MED INS'
which gives me 10......so they all seem the same? sp*******@yahoo.com (SATYA PAL) wrote in message news:<a7**************************@posting.google. com>... Hi There,
There is no issue in UPDATE statement but the data must incorrect stored in the table. Since you are using VARCHAR2 columna and hence it would allow you to store the first 2 character of date greater than 31.
sm********@hotmail.com (Simon) wrote in message news:<c0**************************@posting.google. com>... Hello,
I am trying to update some varchar2 fields, which are storing dates. I am trying to set a 'to date' with the next minumum from date i.e
from date | to date 01/01/1901 01/01/1902 01/01/1902 01/01/1903 01/01/1903 etc......
I have got a bit lost in creating my update statement, but cannot understand why I am geting the following error message:-
ora-01847 day of month must be between 1 and last day of month.
The sql is:-
update emp_add_info_values_tab a set free_column10 = (select b.free_column9 from emp_add_info_values_tab b where a.add_info_type = 'B MED INS' and a.free_column4 not in ('N','W') and a.emp_no = b.emp_no and b.add_info_type = 'B MED INS' and to_date(b.free_column9,'DD/MM/RR') = (select min(to_date(c.free_column9,'DD/MM/RR')) from emp_add_info_values_tab c where c.add_info_type = 'B MED INS' and c.free_column4 not in ('N','W') and a.emp_no = c.emp_no and to_date(c.free_column9,'DD/MM/RR') > to_date(a.free_column9,'DD/MM/RR'))) where exists(select b.free_column9 from emp_add_info_values_tab b where a.add_info_type = 'B MED INS' and a.free_column4 not in ('N','W') and a.emp_no = b.emp_no and b.add_info_type = 'B MED INS' and to_date(b.free_column9,'DD/MM/RR') = (select min(to_date(c.free_column9,'DD/MM/RR')) from emp_add_info_values_tab c where c.add_info_type = 'B MED INS' and c.free_column4 not in ('N','W') and a.emp_no = c.emp_no and to_date(c.free_column9,'DD/MM/RR') > to_date(a.free_column9,'DD/MM/RR')))
Any help would be greatly appreciated...
Cheers,
Simon sm********@hotmail.com (Simon) wrote in message news:<c0**************************@posting.google. com>... not sure if I totally understand your answer...I have looked at the data in the table and cannot see any immediate problems. I have done a length on the fields
select distinct length(b.free_column9) from emp_add_info_values_tab b where b.add_info_type = 'B MED INS'
which gives me 10......so they all seem the same?
Why would you think the length of the text data has anything to do
with it?
sp*******@yahoo.com (SATYA PAL) wrote in message news:<a7**************************@posting.google. com>... Hi There,
There is no issue in UPDATE statement but the data must incorrect stored in the table. Since you are using VARCHAR2 columna and hence it would allow you to store the first 2 character of date greater than 31.
sm********@hotmail.com (Simon) wrote in message news:<c0**************************@posting.google. com>... Hello,
I am trying to update some varchar2 fields, which are storing dates. I am trying to set a 'to date' with the next minumum from date i.e
from date | to date 01/01/1901 01/01/1902 01/01/1902 01/01/1903 01/01/1903 etc......
your sample data has date, month and 4digit year...
I have got a bit lost in creating my update statement, but cannot understand why I am geting the following error message:-
ora-01847 day of month must be between 1 and last day of month.
The sql is:-
update emp_add_info_values_tab a set free_column10 = (select b.free_column9 from emp_add_info_values_tab b where a.add_info_type = 'B MED INS' and a.free_column4 not in ('N','W') and a.emp_no = b.emp_no and b.add_info_type = 'B MED INS' and to_date(b.free_column9,'DD/MM/RR') =
but your conversion format has only the two digit year.
[] and to_date(c.free_column9,'DD/MM/RR') > to_date(a.free_column9,'DD/MM/RR')))
Any help would be greatly appreciated...
Cheers,
Simon
Simon,
Are you a gambling man? I would bet there is at least one, if not many
values in that column like '29/02/1900' or '31/09/1902' or similar bad
dates. Want to take the bet?
BIG HINT: You DO know that 1900 was NOT a leap year, don't you? 8^)
Change your data model and use the DATE type for storing dates and you
won't have this kind of insanity. Or at the very least, clean up your
data. Text fields like this are notorious for getting bad data
somewhere, somehow.
HTH,
Ed ed********@magicinterface.com (Ed prochak) wrote in message news:<4b**************************@posting.google. com>... sm********@hotmail.com (Simon) wrote in message news:<c0**************************@posting.google. com>... not sure if I totally understand your answer...I have looked at the data in the table and cannot see any immediate problems. I have done a length on the fields
select distinct length(b.free_column9) from emp_add_info_values_tab b where b.add_info_type = 'B MED INS'
which gives me 10......so they all seem the same?
Why would you think the length of the text data has anything to do with it?
sp*******@yahoo.com (SATYA PAL) wrote in message news:<a7**************************@posting.google. com>... Hi There,
There is no issue in UPDATE statement but the data must incorrect stored in the table. Since you are using VARCHAR2 columna and hence it would allow you to store the first 2 character of date greater than 31.
sm********@hotmail.com (Simon) wrote in message news:<c0**************************@posting.google. com>... > Hello, > > I am trying to update some varchar2 fields, which are storing dates. I > am trying to set a 'to date' with the next minumum from date i.e > > from date | to date > 01/01/1901 01/01/1902 > 01/01/1902 01/01/1903 > 01/01/1903 etc...... > your sample data has date, month and 4digit year... I have got a bit lost in creating my update statement, but cannot > understand why I am geting the following error message:- > > > ora-01847 day of month must be between 1 and last day of month. > > > The sql is:- > > update emp_add_info_values_tab a > set free_column10 = (select b.free_column9 > from emp_add_info_values_tab b > where a.add_info_type = 'B MED INS' > and a.free_column4 not in ('N','W') > and a.emp_no = b.emp_no > and b.add_info_type = 'B MED INS' > and to_date(b.free_column9,'DD/MM/RR') = but your conversion format has only the two digit year. [] > and to_date(c.free_column9,'DD/MM/RR') > > to_date(a.free_column9,'DD/MM/RR'))) > > > Any help would be greatly appreciated... > > Cheers, > > Simon
Simon,
Are you a gambling man? I would bet there is at least one, if not many values in that column like '29/02/1900' or '31/09/1902' or similar bad dates. Want to take the bet?
BIG HINT: You DO know that 1900 was NOT a leap year, don't you? 8^)
Change your data model and use the DATE type for storing dates and you won't have this kind of insanity. Or at the very least, clean up your data. Text fields like this are notorious for getting bad data somewhere, somehow.
HTH, Ed
Ed,
Thanks for that ..if only I could change the model!!..i am working
with a package solution. The table is designed to hold loads of
different types of code, so it had to be defined as varchar. The
subsection of data I was trying to update had no invalid data
formats...but other values in the same column did, my update statement
must have been wrong because it was these values that were causing the
problem.
I have taken a lazy way out though...i created a table by selecting
the values and updated the new table. I then deleted the old subset of
data and reinserted the values from my new table. It worked and was
only a one-off so I am fairly happy.
Thanks for your help..... sm********@hotmail.com (Simon) wrote in message news:<c0**************************@posting.google. com>...
[]
Ed,
Thanks for that ..if only I could change the model!!..i am working with a package solution. The table is designed to hold loads of different types of code, so it had to be defined as varchar. The subsection of data I was trying to update had no invalid data formats...but other values in the same column did, my update statement must have been wrong because it was these values that were causing the problem.
Not necessarily the update portion, but the WHERE clause. But does
that mean I won the bet? Too bad I didn't put money on it. 8^) I have taken a lazy way out though...i created a table by selecting the values and updated the new table. I then deleted the old subset of data and reinserted the values from my new table. It worked and was only a one-off so I am fairly happy.
So is anyone going to go back and fix the bad dates so this doesn't
happen next time? If you have to stay with VARCHAR at least try to
clean it up. Thanks for your help.....
You are welcome. It is nice to get feedback on whether proposed
solutions really work, so thanks to you too.
Ed ed********@magicinterface.com (Ed prochak) wrote in message news:<4b**************************@posting.google. com>... sm********@hotmail.com (Simon) wrote in message news:<c0**************************@posting.google. com>... []
Ed,
Thanks for that ..if only I could change the model!!..i am working with a package solution. The table is designed to hold loads of different types of code, so it had to be defined as varchar. The subsection of data I was trying to update had no invalid data formats...but other values in the same column did, my update statement must have been wrong because it was these values that were causing the problem. Not necessarily the update portion, but the WHERE clause. But does that mean I won the bet? Too bad I didn't put money on it. 8^)
Always the way isn't it! I would have one thousands on if only bets! I have taken a lazy way out though...i created a table by selecting the values and updated the new table. I then deleted the old subset of data and reinserted the values from my new table. It worked and was only a one-off so I am fairly happy.
So is anyone going to go back and fix the bad dates so this doesn't happen next time? If you have to stay with VARCHAR at least try to clean it up.
I didn't really answer you properly here, the data causing a problem
was not 'date' data, but character based....my where clause just did
not seperate out the correct records...why it didn't is another story,
one that I don't really know!! If you saw some of the data models I
had to work with, you would feel very sorry for me!!! Thanks for your help.....
You are welcome. It is nice to get feedback on whether proposed solutions really work, so thanks to you too.
Ed
cheers...... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: John |
last post by:
Hi
Right password -> ORA-12154: TNS:Could not resolve service name
wrong password => ORA-01017: invalid username/password; logon denied
Tested on a Windows XP client connecting to Oracle on...
|
by: Alan Brown |
last post by:
Hi All,
I've been trying to access an 8.1.6 oracle database,
running on solaris 7, remotely from another solaris
7 server. The remote database server (on the same
subnet, same vlan as the remote...
|
by: Ping |
last post by:
Where can i find the initialization file to change some parameters? This file
used to be init<sid>.ora in previous versions of oracle.
Oracle 9.2 on xp is in question.
Thanks in advance
...
|
by: bdj |
last post by:
Hello!
I have at set of tnsnames.ora. I wich to make an union, e.g. a single file
of it.
How can I do that easy?
Greetings
Bjørn
|
by: Tig |
last post by:
Hi all.
I have a need to connect to an Oracle 7.3.3.5 database. I have a user
who successfully connects to it with her Oracle 7.3 client. I have an
Oracle 9.2 client installed on my machine.
...
|
by: jstmehr4u3 |
last post by:
I just installed ODP.net 10.2.02 on my local machine (Windows XP Pro)
running IIS.
I have created a sample webservice in VS2003, connecting to localhost.
I am getting:...
|
by: CJM |
last post by:
I have a working web application (ASP) which links to an Oracle 10g DB via
OO4O. I'm trying to port it to either of two test servers, but in fact, I
can't get it to work with either - 'Unable to...
|
by: mivey4 |
last post by:
Hi,
First off, I am aware that this is a very heavily documented error and I have done my homework for throughly researching probable causes before deciding to post my problem here. At this point,...
|
by: prashanttarudkar9 |
last post by:
Hi all,
I installed oracle server 9.2.0.4.0 in Windows 2000 professional O.S.
But now I am trying to connect with server, but I got the following error.
ORA-12514: TNS:listener could not...
|
by: hemantmudaliar |
last post by:
The Trigger is giving following exception
java.sql.SQLException: ORA-04091: table PSCONTENT.VGNASCHANNEL is mutating, trigger/function may not see it ORA-06512: at...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |