pratteek shaurya
pratteek shaurya

Reputation: 960

how to execute procedure which has out varchar

I have a package:

CREATE OR REPLACE PACKAGE BODY pack1
AS
    procedure proc1(column_1 in table1.column1%TYPE, column_2 in table1.column2%TYPE, results out varchar)

//code....
......
.....
....//
    END pack1;
/

I want to know how to execute this procedure. I know it's a silly question, But I am very confused about this. I tried this: exec pack1.proc1(123,'abc') But this is not working. Please tell me how to execute this

Upvotes: 0

Views: 136

Answers (1)

Kaushik Nayak
Kaushik Nayak

Reputation: 31686

You may use a bind variable in SQL* Plus to get the results and display it using PRINT

VARIABLE v_result VARCHAR2
EXECUTE pack1.proc1(123, 'abc', :v_result); --note the colon.
PRINT v_result   --display the results.

If you're calling it from a PL/SQL block or another procedure, you may just display it using DBMS_OUTPUT.PUT_LINE()

SET SERVEROUTPUT ON
DECLARE
  l_results VARCHAR2(20);
BEGIN
 pack1.proc1(123, 'abc', l_results);
DBMS_OUTPUT.PUT_LINE(l_results);
END;
/

Note: Use VARCHAR2 instead of VARCHAR as the datatype for procedure parameter results

Upvotes: 2

Related Questions