-1

how to execute this one in plsql..

create or replace procedure p11(a in number, b out number)
is
begin
b:=a*a;
dbms_output.put_line(b);
end;

variable a number;
variable b number;

what statement I have to give to execute; Trying to learn

  • execute p11(10,b) gives b not declared ? – S123DB8 Jan 27 '16 at 15:25
1

Variables you define with the keyword variable can be used as bind variables, not like PL/SQL variables, so you need to add a colon (:).

SQL> variable b number;

SQL> create or replace procedure p11(a in number, b out number)
is
begin
b:=a*a;
dbms_output.put_line(b);
end;
 /

Procedure created.

SQL> exec p11(10, :b);                 <----- ':' in front of b

PL/SQL procedure successfully completed.

SQL> print :b

         B
----------
       100

The line variable a number; has no effect on your program, a is a local variable to p11 from its argument list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.