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 > Error in calling a function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-13-04, 03:02
BKamesh BKamesh is offline
Registered User
 
Join Date: Jul 2004
Posts: 40
Error in calling a function

Hi,

Following EXAMPLE proceudre calls TO_CHAR function which is given below.

CREATE PROCEDURE EXAMPLE()
LANGUAGE SQL
BEGIN ATOMIC
DECLARE VAR VARCHAR(254) DEFUALT ' ';
SET VAR = TO_CHAR(TIMESTAMP('20020202182727'),'DDMMYYHHMMSS' )
END
@

TO_CHAR function:

CREATE FUNCTION TO_CHAR(D TIMESTAMP, FMT VARCHAR(50))
.........
......
..........
END
@

On compiling the EXAMPLE procedure, following error was thrown,

DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0171N The data type, length or value of argument "2" of routine
"SYSIBM.TO_CHAR" is incorrect. LINE NUMBER=6. SQLSTATE=42815.

Can anyone give a solution for this?.

Thanks,
Kamesh.
Reply With Quote
  #2 (permalink)  
Old 07-13-04, 04:23
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
A function by name SYSIBM.TO_CHAR is provided as part of the db2 installation .. Looks like, SYSIBM comes first in your function path ...
VALUES(FUNCTION PATH)

If you want DB2 to take your functions before SYSIBM, then use

SET PATH = SATHYARAM, SYSIBM

But, I would suggest that you change the name of the function you create to avoid any confusions ...

HTH

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 07-14-04, 02:54
BKamesh BKamesh is offline
Registered User
 
Join Date: Jul 2004
Posts: 40
Hi Sathya,

You spotted exactly. Thanks for your immediate solution. I have changed function name and it worked. But, other solution - setting PATH as USERNAME(I guess) had no effect.

TA
Kamesh.
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