Create Function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • japuentem
    New Member
    • Jun 2007
    • 31

    Create Function

    throwing error when creating function

    DB21034E 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 "SULTADO
    DECIMAL(6, 3". Expected tokens may include:
    "END-OF-STATEMENT". LINE NUMBER=8. SQLSTATE=42601

    this is my code

    CREATE FUNCTION MAYORRPK(
    VALUE1 DECIMAL(6, 3),
    VALUE2 DECIMAL(6, 3) )
    RETURNS DECIMAL(6, 3)
    LANGUAGE SQL
    CONTAINS SQL
    NO EXTERNAL ACTION
    BEGIN ATOMIC
    DECLARE RESULTADO DECIMAL(6, 3);
    IF (VALUE1 >= VALUE2) THEN
    SET RESULTADO = VALUE1;
    ELSE
    SET RESULTADO = VALUE2;
    END IF;
    RETURN RESULTADO;
    END ;

    Any suggestions
  • Hevan
    New Member
    • May 2007
    • 17

    #2
    Hi,

    Remove semicolumn (;) after end and try. All the best.



    CREATE FUNCTION MAYORRPK(
    VALUE1 DECIMAL(6, 3),
    VALUE2 DECIMAL(6, 3) )
    RETURNS DECIMAL(6, 3)
    LANGUAGE SQL
    CONTAINS SQL
    NO EXTERNAL ACTION
    BEGIN ATOMIC
    DECLARE RESULTADO DECIMAL(6, 3);
    IF (VALUE1 >= VALUE2) THEN
    SET RESULTADO = VALUE1;
    ELSE
    SET RESULTADO = VALUE2;
    END IF;
    RETURN RESULTADO;
    END

    Comment

    • japuentem
      New Member
      • Jun 2007
      • 31

      #3
      I have the same result

      Originally posted by Hevan
      Hi,

      Remove semicolumn (;) after end and try. All the best.



      CREATE FUNCTION MAYORRPK(
      VALUE1 DECIMAL(6, 3),
      VALUE2 DECIMAL(6, 3) )
      RETURNS DECIMAL(6, 3)
      LANGUAGE SQL
      CONTAINS SQL
      NO EXTERNAL ACTION
      BEGIN ATOMIC
      DECLARE RESULTADO DECIMAL(6, 3);
      IF (VALUE1 >= VALUE2) THEN
      SET RESULTADO = VALUE1;
      ELSE
      SET RESULTADO = VALUE2;
      END IF;
      RETURN RESULTADO;
      END

      Comment

      • gast2007
        New Member
        • Jun 2007
        • 2

        #4
        Looks like you have 1 more "(" than ")"

        Comment

        • Hevan
          New Member
          • May 2007
          • 17

          #5
          This function works fine. did you drop and rebuild the function and run it?

          Comment

          • japuentem
            New Member
            • Jun 2007
            • 31

            #6
            Originally posted by gast2007
            Looks like you have 1 more "(" than ")"
            I counted and i have the same number of "(" and ")"

            Comment

            • japuentem
              New Member
              • Jun 2007
              • 31

              #7
              Originally posted by Hevan
              This function works fine. did you drop and rebuild the function and run it?
              I treated to run with the command editor of db2 and always send me an error.

              i don't know what to do

              Comment

              Working...