Home » Developer & Programmer » Forms » Error while inserting date column
icon5.gif  Error while inserting date column [message #599946] Wed, 30 October 2013 06:34 Go to next message
stalin4d
Messages: 226
Registered: May 2010
Location: Chennai, Tamil Nadu, Indi...
Senior Member
I am trying to insert some values into a table from a form i get the below error;
which says not a valid month;

FRM-40735 WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-01843


after i do google i added the below one to the insert statement and again i receive the error;

to_date(to_char(sysdate,'dd/mm/yyyy'),'dd/mm/yyyy')


My Insert Statement

insert into Invoice123
      (Invoiceno, invdate, gross_tot, discount)
    values
      (nvl(INVOICEno(j),0),
      to_date(to_char(invdate(j),'dd/mm/yyyy'),'dd/mm/yyyy'));
commit;    


by which format we can achieve this!

Re: Error While Insert Date Column! [message #599947 is a reply to message #599946] Wed, 30 October 2013 06:39 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
This:
to_date(to_char(sysdate,'dd/mm/yyyy'),'dd/mm/yyyy')
doesn't make any sense. SYSDATE is a function that returns date; there's no point in converting it to character, and then back to date.

Error you got is caused by values stored in INVDATE(j). What is its datatype? If it is date, you don't need any conversion function. If it is character, then TO_DATE is all you need, with appropriate date format mask. It means that you have to know in which format you stored values in there. Here we come, again, to conclusion that storing date values into character datatype columns leads to problems.
Re: Error While Insert Date Column! [message #599951 is a reply to message #599947] Wed, 30 October 2013 07:02 Go to previous messageGo to next message
stalin4d
Messages: 226
Registered: May 2010
Location: Chennai, Tamil Nadu, Indi...
Senior Member
The data for insert values is in a Varchar2 datatype,
that is to be inserted into a table which is already a Date datatype.

pls note that in the values table the data is stored as 'MM/DD/YYYY'
format. so how to achieve this?
Re: Error While Insert Date Column! [message #599953 is a reply to message #599951] Wed, 30 October 2013 07:09 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
You must be kidding, right?

If data is stored as 'MM/DD/YYYY', why did you use to_date(to_char(invdate(j),'dd/mm/yyyy'),'dd/mm/yyyy') (which is wrong, as I already said; TO_DATE is enough).
Re: Error While Insert Date Column! [message #599955 is a reply to message #599953] Wed, 30 October 2013 07:20 Go to previous messageGo to next message
stalin4d
Messages: 226
Registered: May 2010
Location: Chennai, Tamil Nadu, Indi...
Senior Member
Yes little, u are right but its again giving the same error,

FRM-40735 WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-01843


Why?
Re: Error While Insert Date Column! [message #599957 is a reply to message #599955] Wed, 30 October 2013 07:31 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Then not all values comply to the MM/DD/YYYY format.
Re: Error While Insert Date Column! [message #599962 is a reply to message #599957] Wed, 30 October 2013 08:27 Go to previous message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Or you're still using incorrect code, post the revised code.
Previous Topic: control enable status of block at run time
Next Topic: pop list values
Goto Forum:
  


Current Time: Fri Apr 26 16:04:58 CDT 2024