Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Location
    BRAZIL
    Posts
    10

    Angry Unanswered: Error in creating function

    Anyone could tell me whats wrong with my function ? (Its the first one that Im doing.Im 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

    Ive 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

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650

    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.

  3. #3
    Join Date
    Jan 2004
    Location
    BRAZIL
    Posts
    10

    Talking Re: Error in creating function

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •