niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Oracle
Please Help: ORA-01847 for valid date
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
Author Message
Ken Denny
*nix forums beginner


Joined: 08 Apr 2005
Posts: 16

PostPosted: Wed Feb 23, 2005 7:08 pm    Post subject: Re: Please Help: ORA-01847 for valid date Reply with quote

wdewebserver wrote:
Quote:
Hi

I have written the following stored procedure hoping to extract data
from a
table. When I call the stored proc using a date like 10-11-2004, I
get an
error ORA-01847: day of month must be between 1 and last day of
month.

Procedure "dynamic"
(
vTABLE_NAME IN CHAR,
vCREATED_DATE IN CHAR,
vREF_CURSOR OUT GLOA.RCT
)
AS
V_STRING VARCHAR2(1000);
BEGIN
V_STRING := 'SELECT XRED, YFER FROM '||vTABLE_NAME||' '||
'WHERE CREATED_DATE =
TO_DATE('||vCREATED_DATE||',''DD-MM-YYYY'')'

OPEN vREF_CURSOR FOR V_STRING;
END dynamic;

Probably because you need quotes around the created_date in the query
V_STRING := 'SELECT XREF, YFER FROM '||vTABLE_NAME||' '||
'WHERE CREATED_DATE = TO_DATE('''||vCREATED_DATE||''',''DD-MM-YYYY'')'

Also are you sure created_date in the table is a truncated date? If
it's not you will only get those whose time portion is midnight. You
may want to say "WHERE trunc(CREATED_DATE) = ".

Good luck with it
Ken Denny
Back to top
casey.kirkpatrick@gmail.c
*nix forums beginner


Joined: 08 Jun 2005
Posts: 20

PostPosted: Tue Feb 22, 2005 7:03 pm    Post subject: Re: Please Help: ORA-01847 for valid date Reply with quote

It's called debugging.

Rather than OPEN your V_STRING (and report errors to a public
discussion board), why not print V_STRING, and see what your SELECT
actually looks like.
Back to top
DA Morgan
*nix forums Guru


Joined: 06 Mar 2005
Posts: 1042

PostPosted: Tue Feb 22, 2005 6:46 pm    Post subject: Re: Please Help: ORA-01847 for valid date Reply with quote

wdewebserver wrote:

Quote:
Hi

I have written the following stored procedure hoping to extract data from a
table. When I call the stored proc using a date like 10-11-2004, I get an
error ORA-01847: day of month must be between 1 and last day of month.

Procedure "dynamic"
(
vTABLE_NAME IN CHAR,
vCREATED_DATE IN CHAR,
vREF_CURSOR OUT GLOA.RCT
)
AS
V_STRING VARCHAR2(1000);
BEGIN
V_STRING := 'SELECT XRED, YFER FROM '||vTABLE_NAME||' '||
'WHERE CREATED_DATE = TO_DATE('||vCREATED_DATE||',''DD-MM-YYYY'')'

OPEN vREF_CURSOR FOR V_STRING;
END dynamic;

Change CHAR to VARCHAR2. Likely you are padding vTABLE_NAME and
v_CREATED_DATE out to 2000 bytes.
--
Daniel A. Morgan
University of Washington
damorgan@x.washington.edu
(replace 'x' with 'u' to respond)
Back to top
wdewebserver
*nix forums beginner


Joined: 22 Feb 2005
Posts: 5

PostPosted: Tue Feb 22, 2005 6:06 pm    Post subject: Please Help: ORA-01847 for valid date Reply with quote

Hi

I have written the following stored procedure hoping to extract data from a
table. When I call the stored proc using a date like 10-11-2004, I get an
error ORA-01847: day of month must be between 1 and last day of month.

Procedure "dynamic"
(
vTABLE_NAME IN CHAR,
vCREATED_DATE IN CHAR,
vREF_CURSOR OUT GLOA.RCT
)
AS
V_STRING VARCHAR2(1000);
BEGIN
V_STRING := 'SELECT XRED, YFER FROM '||vTABLE_NAME||' '||
'WHERE CREATED_DATE = TO_DATE('||vCREATED_DATE||',''DD-MM-YYYY'')'

OPEN vREF_CURSOR FOR V_STRING;
END dynamic;
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [4 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 5:17 am | All times are GMT
navigation Forum index » Databases » Oracle
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Problem with Date::Manip Ted Byers Perl 1 Fri Jul 21, 2006 4:23 am
No new posts Last login date Evan Ehrenhalt Server 1 Thu Jul 20, 2006 10:07 pm
No new posts How to query on part of a date column? Barry Newton MySQL 4 Thu Jul 20, 2006 5:02 pm
No new posts Problem with SQLLoader Date columns and JDBC access Thomas Kellerer Oracle 2 Wed Jul 19, 2006 7:33 am
No new posts strange problem using DATE fields from coldfusion/MX (jdbc) yoram.ayalon@structuredwe Server 6 Tue Jul 18, 2006 11:06 pm

Budapest | Yugioh | Credit Cards | Mobile Phones | Credit Score
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1183s ][ Queries: 20 (0.0397s) ][ GZIP on - Debug on ]