Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2013
    Posts
    4

    Unanswered: Define a procedure thet calls a function

    Ho scritto una procedura che chiama una funzione per๒ durante la compilazione mi da errore, di seguito la funzione e la procedura :

    1) function :

    CREATE FUNCTION TOT_CALC ()
    RETURNS INTEGER
    NO EXTERNAL ACTION
    F1: BEGIN ATOMIC
    RETURN
    SELECT SUM(COSTO_PROJ) FROM TB_PROGETTI;
    END

    2) procedure :

    CREATE PROCEDURE provacallc ()
    DYNAMIC RESULT SETS 1
    P2: BEGIN
    declare deltacall int;
    declare inp int;
    set deltacall = 12;
    call TOT_CALC (deltacall, INP);
    END P2

    Creazione di procedura memorizzata restituzioni SQLCODE: -440, SQLSTATE: 42884.
    PROVACALLC: 7: Non ่ stata rilevata alcuna routine autorizzata denominata "TOT_CALC" di tipo "PROCEDURE" con argomenti compatibili.. SQLCODE=-440, SQLSTATE=42884, DRIVER=4.12.79


    grazie

  2. #2
    Join Date
    Apr 2008
    Location
    Iasi, Romania
    Posts
    561
    Provided Answers: 2
    1. Your function has no parameters (CREATE FUNCTION TOT_CALC ()) but you are calling it with 2 parameters (call TOT_CALC (deltacall, INP))
    2. You should try writting your messages in English instead of Italian. You would have more changes in getting a reponse.
    Florin Aparaschivei
    DB2 9.7, 10.5 on Windows
    Iasi, Romania

  3. #3
    Join Date
    Jun 2013
    Posts
    4
    Thank ! I tried without parameters and obtained the same message : SQLCODE: -440 , SQLSTATE:. 42884 this message occurred during compiling and distribution of the module into server of the database.

    Help me !

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    You don't call functions using the CALL statement. Functions are references in SET statements or in SELECTs.
    ---
    "It does not work" is not a valid problem statement.

  5. #5
    Join Date
    Jun 2013
    Posts
    4
    Thanks !

    Please, can you send me how i must write the comand SET ?

  6. #6
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Quote Originally Posted by nato1952 View Post

    Please, can you send me how i must write the comand SET ?
    It's in the manuals. Your function is not valid either. You declare that you return an integer, but in fact you are attempting to return a row, I don't think it will work that way.

    You probably need to review samples provided with DB2, as well as the application development guides IBM DB2 Version 10.1 for Linux, UNIX, and Windows English manuals - United States.
    ---
    "It does not work" is not a valid problem statement.

  7. #7
    Join Date
    Jun 2013
    Posts
    4
    Help !

    I must call a function called CalcTot and to pass two parameters X , Y. What are the correct statements into program calling to call a function ?

    I wrote into calling so :

    set Fieldcall=Calc_tot(x,y);
    Calc_tot(x,y);

    but the callinh not execute the call to the function Calc_tot!

    thanks

Posting Permissions

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