Calling a stored procedure in Oracle with IN and OUT parameters

后端 未结 3 1189
我在风中等你
我在风中等你 2020-12-08 00:38

I have this procedure:

CREATE OR REPLACE PROCEDURE PROC1(invoicenr IN NUMBER, amnt OUT NUMBER)
AS BEGIN
SELECT AMOUNT INTO amnt FROM INVOICE WHERE INVOICE_NR         


        
相关标签:
3条回答
  • 2020-12-08 01:00

    Go to Menu Tool -> SQL Output, Run the PL/SQL statement, the output will show on SQL Output panel.

    0 讨论(0)
  • 2020-12-08 01:08

    If you set the server output in ON mode before the entire code, it works, otherwise put_line() will not work. Try it!

    The code is,

    set serveroutput on;
    CREATE OR REPLACE PROCEDURE PROC1(invoicenr IN NUMBER, amnt OUT NUMBER)
    AS BEGIN
    SELECT AMOUNT INTO amnt FROM INVOICE WHERE INVOICE_NR = invoicenr;
    END;
    

    And then call the function as it is:

    DECLARE
    amount NUMBER;
    BEGIN
    PROC1(1000001, amount);
    dbms_output.put_line(amount);
    END;
    
    0 讨论(0)
  • 2020-12-08 01:09

    I had the same problem. I used a trigger and in that trigger I called a procedure which computed some values into 2 OUT variables. When I tried to print the result in the trigger body, nothing showed on screen. But then I solved this problem by making 2 local variables in a function, computed what I need with them and finally, copied those variables in your OUT procedure variables. I hope it'll be useful and successful!

    0 讨论(0)
提交回复
热议问题