DB2 9.7 Function + NickName + Dynamic=> Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • medoed
    New Member
    • Mar 2013
    • 3

    DB2 9.7 Function + NickName + Dynamic=> Problem

    Good day! Sorry for my bad English! I am from Russia.

    I want to write scalar function (Return String), This Function work with dynamic scripts and use NickName.
    Ок.

    This is Procedure, what get SQL QWERY and after dynamic work Return STRING.

    Code:
    CREATE OR REPLACE PROCEDURE TEMP.RETURN_STR
    (IN IN_STR   VARCHAR(32000), 
     OUT OUT_STR VARCHAR(32000)
    ) 
    LANGUAGE SQL
    NOT DETERMINISTIC
    CALLED ON NULL INPUT
    NO EXTERNAL ACTION
    OLD SAVEPOINT LEVEL
    READS SQL DATA
    INHERIT SPECIAL REGISTERS
    BEGIN
    DECLARE c1 CURSOR FOR s1;
    PREPARE s1 FROM IN_STR;
    OPEN c1;
    FETCH c1 INTO OUT_STR;
    CLOSE c1;
    RETURN;
    END;
    */It is example function, what use NickName
    FORM.FUND - it is NickName
    */

    Code:
    CREATE OR REPLACE FUNCTION TEMP.TESTSC ()
      RETURNS VARCHAR(32000)
    LANGUAGE SQL
    NOT DETERMINISTIC
    READS SQL DATA
    STATIC DISPATCH
    CALLED ON NULL INPUT
    NO EXTERNAL ACTION
    INHERIT SPECIAL REGISTERS
    BEGIN ATOMIC  
    DECLARE STR_RESULT VARCHAR(32000);
    DECLARE STR_EXEC   VARCHAR(32000);
    
    SET STR_EXEC =  'select MAX(ID_PERSON) from FORM.FUND where ID_PERSON_FUND_PARENT  <50';
    CALL TEMP.RETURN_STR (STR_EXEC,STR_RESULT);
    RETURN cast(STR_RESULT as VARCHAR(32000));
    END;
    select TEMP.TESTSC() from SYSIBM.SYSDUMMY1;
    When i execute , i get error:
    Lookup Error - DB2 Database Error: ERROR [55047] [IBM][DB2/NT64] SQL20136N Routine "TEMP.RETURN_ST R" (specific name "SQL13032211043 4800") attempted to access a federated object.

    Please, Help Me!
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    When allowing SQL in a procedure, you're not allowed to call a federated object.

    Comment

    • medoed
      New Member
      • Mar 2013
      • 3

      #3
      Ок! Thanks!
      But Procedure - in not important! I want use Nickname with dynamic in function. Why function - because i will use this function in construction from.
      It is realy or i am dreamer?

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        You haven't added any additional information.

        You need to either not allow SQL and convert any SQL to non-SQL code or you need to find an alternative to your federated object.

        Comment

        • medoed
          New Member
          • Mar 2013
          • 3

          #5
          OK! I tried select * from scalar function with nickname - no problem. I tried dinamic in function - no problem. But , when i use NickName + Dynamic in SQL function i get problem. Why?

          I do'nt undestand, what you mean:
          1) >>You need to either not allow SQL and convert any SQL to non-SQL code.
          If You mean - java or C external function - i tried, but i get identical error.
          2) >>You need to find an alternative to your federated object.
          If You say about MQT - it is not good for us. MQT - is evil, on big table we have long refresh and deadlock.

          Comment

          Working...