Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2007
    Posts
    47

    Unanswered: 9.7 function create problem

    I'm trying to create this function in Control Center, but having some problems with the syntax:

    Code:
    CREATE FUNCTION findMax (tablename VARCHAR(64), columnname VARCHAR(255))
    RETURNS INTEGER 
    LANGUAGE SQL
    NO EXTERNAL ACTION
    BEGIN ATOMIC
    RETURN
    SELECT MAX(columnname) FROM tablename;--
    END;

    DB21034E The command was processed as an SQL statement because it was not a
    valid Command Line Processor command. During SQL processing it returned:
    SQL0204N "DB2ADMIN.TABLENAME" is an undefined name. LINE NUMBER=6.
    SQLSTATE=42704

    SQL0204N "DB2ADMIN.TABLENAME " is an undefined name.

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by bic View Post
    "DB2ADMIN.TABLENAME" is an undefined name
    So, what part of the message do you find confusing?
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    You will not be able to use parameters as column names and table names in static SQL. You will have to turn it into dynamic SQL.

    Andy

Posting Permissions

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