If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL0440N : Setting Date to Variable

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-12-04, 15:50
ChanOnna ChanOnna is offline
Registered User
 
Join Date: Dec 2003
Posts: 8
Question SQL0440N : Setting Date to Variable

Hi,

I'm having some trouble converting an integer to a date and setting it to a variable...

Here is the code:

...

DECLARE D_FROMSTARTDATE DATE;

SET D_FROMSTARTDATE = DATE (SUBSTR(CHAR(P_FROMDATE),5,2) || '/' || SUBSTR(CHAR(P_FROMDATE),7,2) || '/' || SUBSTR(CHAR(P_FROMDATE),1,4) );

...

P_FROMDATE is a parameter, coming in as an INTEGER.

The error message when trying to deploy the stored procedure is:

SQL0440N No Authorized routine named "SUBSTR" of type "FUNCTION" having compatible arguements was found.


Thanks for any advice.
Reply With Quote
  #2 (permalink)  
Old 04-12-04, 16:34
nidm nidm is offline
Registered User
 
Join Date: May 2003
Posts: 113
Re: SQL0440N : Setting Date to Variable

It looks ok.
Is it possible that P_FROMDATE is a smallint, which cause
SUBSTR(CHAR(P_FROMDATA),7,2) out of range?

Would you please give a result of
CHAR(P_FROMDATA), and LENGTH(CHAR(P_FROMDATA)) inside your stored proc?

BTW, which db2 you are using? db2 for LUW(linux/unix/windows) for db2 for 390?

Quote:
Originally posted by ChanOnna
Hi,

I'm having some trouble converting an integer to a date and setting it to a variable...

Here is the code:

...

DECLARE D_FROMSTARTDATE DATE;

SET D_FROMSTARTDATE = DATE (SUBSTR(CHAR(P_FROMDATE),5,2) || '/' || SUBSTR(CHAR(P_FROMDATE),7,2) || '/' || SUBSTR(CHAR(P_FROMDATE),1,4) );

...

P_FROMDATE is a parameter, coming in as an INTEGER.

The error message when trying to deploy the stored procedure is:

SQL0440N No Authorized routine named "SUBSTR" of type "FUNCTION" having compatible arguements was found.


Thanks for any advice.
Reply With Quote
  #3 (permalink)  
Old 04-13-04, 00:14
famudba famudba is offline
Registered User
 
Join Date: Jan 2004
Location: Tallahassee, FL, USA
Posts: 96
If your value is comming as integer , DATE function automaticaly convert into date, no need to convert to char & substring it.


example is as below

db2 select date(1967) from sysibm.sysdummy1

1
----------
05/21/0006

1 record(s) selected.


Let me know if any questions .


Thank You


Lekharaju Ennam
Certified Oracle8i & DB2 UDB DBA
Florida A&M University
Reply With Quote
  #4 (permalink)  
Old 04-14-04, 10:45
ChanOnna ChanOnna is offline
Registered User
 
Join Date: Dec 2003
Posts: 8
Thank you both for your replies.

After seeing your answers, I felt a little more confident with the syntax, and did a little more testing. I actually had a similar date conversion at the end of the script where I left out the CHAR after the SUBSTR.

After adding CHAR to the line, it deployed successfully.

Thanks again for your input.

Best,
Chanonna
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On