How to easily check the return value of a function in PL/SQL Developer

10,835

Solution 1

1) there is a "sort of" output window: try to execute this in a sql window (or in a test window

  begin
        DBMS_OUTPUT.PUT_LINE( 'hello world');
  end;

you should see "hello world" in the "output" tab of the sql window/test window. if you don't see it, just be sure that the "enabled" checkbox in such tab is checked.

2) if your function has no side effects (it does modify table data during its execution) you can use it in a select statement, as @a_horse_with_no_name already told you.

3) to see compilation errors be sure to compile procedures/triggers/functions/packages inside a "program window". a program window is the pl/sql developer window designed exactly for editing code that has to be compiled. it shows you compilation errors, hints, has code folding, refactorings...

4) if you want to run your funcition inside a debugger, you should use a "test window". I suggest you to give a read to the manual of pl/sql developer first.

Solution 2

I just simply want to check the result of this function.

You could simply call the function in the SELECT statement.

For example,

SQL> CREATE OR REPLACE
  2    FUNCTION f_get_date
  3      RETURN DATE
  4    IS
  5      v_date DATE;
  6    BEGIN
  7      v_date := SYSDATE;
  8      RETURN v_date;
  9    END;
 10  /

Function created.

SQL>
SQL> sho err
No errors.
SQL>
SQL> SELECT f_get_date FROM dual;

F_GET_DATE
--------------------
27-AUG-2015 17:06:31

SQL>

If you are new to PL/SQL Developer tool, you might find PL/SQL Developer Settings helpful.

Share:
10,835
tete
Author by

tete

Updated on June 26, 2022

Comments

  • tete
    tete almost 2 years

    Totally newbie with database. Now I have created a function which returns a NUMBER, I just simply want to check the result of this function. The tool I am using is PL/SQL Developer but I can't find a output window or whatever. And of course I don't want to write anything into any table in this case. As a C++/C# developer I find it a bit hard to learn how to develop PL/SQL. I can't even easily see the compilation error of my function.