Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Posts
    2

    Unanswered: Problem with a function

    I create a function that is very simple actually, but somehow it doesn't work and i can't figure out why,this is my function:

    function calcular_posicion_nivel(definitiva pro_promedios_alumno.promdef%TYPE,nivel pro_grados.cnivel%TYPE)

    return number is

    total number(4):=0;
    posicion number(4):=0;
    repeticion number(2):=0;
    resultado number(4):=0;

    begin

    select count(*) into total from pro_promedios_alumno pa,pro_alumnos_x_grados_seccion axgs,
    pro_grados g where g.cnivel=nivel and axgs.cgrado=g.cgrado and axgs.cusuario=pa.cusuario;

    select count(*) into posicion from pro_promedios_alumno pa,pro_alumnos_x_grados_seccion axgs,
    pro_grados g where pa.promdef<definitiva and g.cnivel=nivel and axgs.cgrado=g.cgrado and
    axgs.cusuario=pa.cusuario ;

    select count(*) into repeticion from pro_promedios_alumno pa,pro_alumnos_x_grados_seccion axgs,
    pro_grados g where pa.promdef=definitiva and g.cnivel=nivel and axgs.cgrado=g.cgrado and
    axgs.cusuario=pa.cusuario;

    resultado =: total-posicion-repeticion-1;

    return resultado;

    END CALCULAR_POSICION_NIVEL;

    all the select parts work fine separately, so i dont know what could it be the problem. When i try to use the function i get the ORA-06575 ERROR function name is in an invalid state

    I would appreciate any help

    Thanks!

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Problem with a function

    In SQL Plus, type:

    show errors function calcular_posicion_nivel

  3. #3
    Join Date
    Nov 2003
    Location
    Berlin, Germany
    Posts
    6

    Re: Problem with a function

    Originally posted by Karin1012
    ....
    resultado =: total-posicion-repeticion-1;
    ....
    Seemed You switched : and = !
    But I'm not sure, that this would cause a "..invalid state" error.
    Did You altered some of the tables You use in Your function after compiling it? Try to recompile the function.

  4. #4
    Join Date
    Nov 2003
    Posts
    2
    Thanks all for your help. I find out the error. It was a little syntax mistake...

Posting Permissions

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