473,809 Members | 2,668 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ora-01847 when updating a record...please help

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_va lues_tab a
set free_column10 = (select b.free_column9
from emp_add_info_va lues_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.f ree_column9,'DD/MM/RR')) from
emp_add_info_va lues_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_va lues_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.f ree_column9,'DD/MM/RR')) from
emp_add_info_va lues_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
Jul 19 '05 #1
6 8621
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********@hotm ail.com (Simon) wrote in message news:<c0******* *************** ****@posting.go ogle.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_va lues_tab a
set free_column10 = (select b.free_column9
from emp_add_info_va lues_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.f ree_column9,'DD/MM/RR')) from
emp_add_info_va lues_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_va lues_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.f ree_column9,'DD/MM/RR')) from
emp_add_info_va lues_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

Jul 19 '05 #2
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_c olumn9)
from emp_add_info_va lues_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.go ogle.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********@hotm ail.com (Simon) wrote in message news:<c0******* *************** ****@posting.go ogle.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_va lues_tab a
set free_column10 = (select b.free_column9
from emp_add_info_va lues_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.f ree_column9,'DD/MM/RR')) from
emp_add_info_va lues_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_va lues_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.f ree_column9,'DD/MM/RR')) from
emp_add_info_va lues_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

Jul 19 '05 #3
sm********@hotm ail.com (Simon) wrote in message news:<c0******* *************** ****@posting.go ogle.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_c olumn9)
from emp_add_info_va lues_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.go ogle.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********@hotm ail.com (Simon) wrote in message news:<c0******* *************** ****@posting.go ogle.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_va lues_tab a
set free_column10 = (select b.free_column9
from emp_add_info_va lues_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
Jul 19 '05 #4
ed********@magi cinterface.com (Ed prochak) wrote in message news:<4b******* *************** ****@posting.go ogle.com>...
sm********@hotm ail.com (Simon) wrote in message news:<c0******* *************** ****@posting.go ogle.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_c olumn9)
from emp_add_info_va lues_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.go ogle.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********@hotm ail.com (Simon) wrote in message news:<c0******* *************** ****@posting.go ogle.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_va lues_tab a
> set free_column10 = (select b.free_column9
> from emp_add_info_va lues_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.....
Jul 19 '05 #5
sm********@hotm ail.com (Simon) wrote in message news:<c0******* *************** ****@posting.go ogle.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
Jul 19 '05 #6
ed********@magi cinterface.com (Ed prochak) wrote in message news:<4b******* *************** ****@posting.go ogle.com>...
sm********@hotm ail.com (Simon) wrote in message news:<c0******* *************** ****@posting.go ogle.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......
Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
15634
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 an AIX server. Using toad and sqlplusw Everything working fin connecting to other 8.1.7 Oracle servers on windows
1
6771
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 clients running on solaris 7) can be tnspinged. However, a sqlplus session returns the following error - *********************************************** SQL*Plus: Release 8.1.6.0.0 - Production on Sat Nov 1 13:45:14 2003
2
3953
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 Ping
6
4699
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
4
4828
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. I had her send me her tnsnames.ora from her PC. The entry I wanted was as follows (some letters replaced with xxx for security reasons): xxxora2_prod2 = (DESCRIPTION=
5
17106
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: Oracle.DataAccess.Client.OracleException ORA-12154: TNS:could not resolve the connect identifier specified at Oracle.DataAccess.Client.OracleException.HandleErrorHelper(Int32 errCode, OracleConnection conn, IntPtr opsErrCtx, OpoSqlValCtx* pOpoSqlValCtx, Object src,...
8
25622
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 make connection, ORA-12154: TNS:could not resolve the connect identifier specified'. This error occurs in the applications global.asa file where I'm trying to set up a connection pool: <object runat="Server" scope="Application" id="oSession"...
5
38839
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, I believe another set of eyes on the issue is merited. I am a MSSQL DBA and somewhat new to ORACLE; but I have read the administrators manual having a basic thorough level of knowledge (Tho' I am still learning) and understanding of how to...
2
7633
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 resolve SERVICE_NAME given in connect descriptor . Even I checked sqlnet.ora, tnsnames.ora and listner.ora file, it all are proper. Kindly, guide me for it. It is very needful to me.
2
6324
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 "PSCONTENT.CHECK_CHANNEL_UNPUBLISH", line 4 ORA-06512: at "PSCONTENT.CHECK_CHANNEL_UNPUBLISH_TR", line 1 ORA-04088: error during execution of trigger ................................ // Trigger CREATE OR REPLACE TRIGGER check_channel_unpublish_tr before delete ON...
0
9603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10643
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10391
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7664
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4333
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3862
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.