Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2010
    Posts
    11

    Unanswered: How to assign value to a local variable in a UDF

    Hi all,

    I am new to DB2 Programming.

    I am required to write an UDF that takes a table name as input parameter and returns sequence number based on production or DR servername.

    Questions:

    How do I assign a value to a local variable within this UDF?

    For Example:

    Below is the query to find the server name. This query returns "DFORT001"
    How do we store this value in a local variable (v_server) within UDF? What is the syntax?

    SELECT CURRENT SERVER FROM SYSIBM.SYSDUMMY1



    SELECT v_server = CURRENT SERVER FROM SYSIBM.SYSDUMMY1; => This gives error
    SELECT CURRENT SERVER INTO :v_server FROM SYSIBM.SYSDUMMY1; => This gives error
    SELECT CURRENT SERVER INTO v_server FROM SYSIBM.SYSDUMMY1; => This gives error

    OR CAN WE DO THIS?

    SET v_server = (SELECT CURRENT SERVER FROM SYSIBM.SYSDUMMY1);

    What would be best approach?

    Thanks,
    Balu

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    The SET should work.

    Andy

  3. #3
    Join Date
    Jul 2009
    Location
    NY
    Posts
    963
    You have to find the shortest way, if you are professional programmer:

    SET :v_server = CURRENT SERVER;

    SET :var_timestamp = CURRENT TIMESTAMP;

    Lenny

Posting Permissions

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