On January 27th, this site will be read-only as we migrate to Oracle Forums for an improved community experience. You will not be able to initiate activity until January 30th, when you will be able to use this site as normal.

    Forum Stats

  • 3,889,532 Users
  • 2,269,755 Discussions


How to fix this error?



  • jdev1
    jdev1 Member Posts: 222 Green Ribbon

    So it means that in_dep_id is valid?

  • Alex Nuijten
    Alex Nuijten Member Posts: 242 Silver Badge
    edited Jan 26, 2021 1:52PM

    The procedure doesn't have any DBMS_OUTPUT in it (anymore) so there will not be any output in the DBMS output buffer.

    There are two possible errors:

    1) when you pass a NULL

    2) when the department doesn't exist.

    When you pass in 50, the procedure will complete successfully without exceptions.

    If you put a DBMS_OUTPUT after the select count(*), like

    sys.dbms_output.put_line ('Count: '||to_char (l_count));

    you will see something in the DBMS output buffer (if switched on, of course)

  • jdev1
    jdev1 Member Posts: 222 Green Ribbon

    Ok, thanks I added dbms.. output and saw the output. Now I have another issue similar to departments. Whenever I test code

    create or replace procedure triangles(a in out number, b in out number, c in out number) is
     ex_invalid_id exception;
    if c is null and a is not null and b is not null then
    elsif b is null and a is not null and c is not null then
    elsif a is null and b is not null and c is not null then
     a:= sqrt((c**2)-(b**2));
     RAISE ex_invalid_id;
     ---raise_application_error(-20000,'Undefined triangle');
    end if;
      WHEN ex_invalid_id THEN 
       dbms_output.put_line('ORA-20000: Undefined triangle');
    end triangles;

    After testing I am getting this error:

    DESCRP: Consider right triangle with legs A and B and hypotenuse C. Create a procedure with parameters A, B and C for

    calculating length of one of the triangle sides. When calling the procedure any two parameters should contain values

    while the third one should be NULL. The procedure should calculate the missing length and return it via the

    respective parameter-A, B or C – the one which initially was NULL. If more than one parameter is passed as NULL

    the procedure should raise an error: ORA-20000: Undefined triangle

    Hint: Pythagorean theorem: a2+b2=c


  • RogerT
    RogerT Consultant SwitzerlandMember Posts: 1,862 Gold Trophy

    So as those parameters are of type in/out you need to provide variables where the result of the procedure can be stored in instead of passing literals.

       l_variableA number := 5;
       triangles (a => l_variableA, ...);
       sys.dbms_output.put_line('A : ' || to_char(l_variableA));

    and please ... do not open one thread to ask x questions ...

  • Alex Nuijten
    Alex Nuijten Member Posts: 242 Silver Badge

    ... isn't it time to close this thread and start a new one?

  • jdev1
    jdev1 Member Posts: 222 Green Ribbon
  • mathguy
    mathguy Member Posts: 11,039 Black Diamond


    Did you change the subject?

    I see there are 30 more replies or so, after my last one. I thought you were close to an answer already. Now I see a lot of new replies and code that seem to have absolutely nothing to do with your original question.

    If that is indeed so, then please read again the "rules of the game". If you have a different question, don't post it in a thread that was about something else - start a different thread.

  • jdev1
    jdev1 Member Posts: 222 Green Ribbon

    Ok I see, thanks, I try follow the rules.

  • jdev1
    jdev1 Member Posts: 222 Green Ribbon

    I have checked above code and I always getting : raise_application_error(-20001,'Null parameter is passed.')?