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 creating function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-21-04, 08:51
Silvana.meira Silvana.meira is offline
Registered User
 
Join Date: Jan 2004
Location: BRAZIL
Posts: 10
Angry Error in creating function

Anyone could tell me what´s wrong with my function ? (It´s the first one that I´m doing.I´m trying to migrate from Oracle to DB2).

CREATE FUNCTION LPADN(P_COLUNA integer, P_TAMANHO smallint, P_CARACTER CHAR(1))
RETURNS varchar(30)
NO EXTERNAL ACTION
DETERMINISTIC
LANGUAGE SQL
CONTAINS SQL
BEGIN ATOMIC
DECLARE V_COL varchar(30);
DECLARE V_TAM bigint;
SET V_COL=0;
SET V_TAM=1;
IF P_COLUNA IS NULL OR P_TAMANHO IS NULL OR P_CARACTER IS NULL THEN
RETURN NULL;
END IF;
SET (V_TAM, V_COL) =( LENGTH(P_COLUNA) - 1, P_CARACTER) ;
WHILE V_TAM < P_TAMANHO DO
set V_COL = P_CARACTER||V_COL;
set V_TAM = V_TAM + 1;
END WHILE;
set V_COL = V_COL||P_COL;
RETURN V_COL;
END

I´ve got the error:

DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token ")" was found following "RE V_COL varchar(30".
Expected tokens may include: "END-OF-STATEMENT". LINE NUMBER=8.
SQLSTATE=42601
__________________
Silvana Meira
Reply With Quote
  #2 (permalink)  
Old 01-21-04, 09:11
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Re: Error in creating function

Are you doing this from the command line ?

If so, terminate your function defn with @ , save in a file and issue

db2 -td@ -f<filename>

HTH
Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 01-21-04, 11:47
Silvana.meira Silvana.meira is offline
Registered User
 
Join Date: Jan 2004
Location: BRAZIL
Posts: 10
Talking Re: Error in creating function

Quote:
Originally posted by sathyaram_s
Are you doing this from the command line ?

If so, terminate your function defn with @ , save in a file and issue

db2 -td@ -f<filename>

HTH
Sathyaram
Ok! That was the problem !!!!
Thank you,very much !!!
__________________
Silvana Meira
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