0

How can I execute the below Stored Procedure?

create or replace procedure squareOf(x IN OUT NUMBER) is
begin
 x:= x*x;
end;

3 Answers 3

3

@Massie already mentioned one approach using anonymous block.

Another approach is using bind variable in command line like below -

var c number;
exec :c:= 6;
execute squareOf(:c);
print c;
Sign up to request clarification or add additional context in comments.

Comments

3

Since you're asking about 'in SQL Developer' - here's the answer from the IDE perspective.

  1. Find your procedure in your database navigation tree.
  2. Click or double-click to open in a plsql editor
  3. Hit the Execute Button in the toolbar
  4. Supply required input values and hit OK to execute
  5. Observe any output returned in the bottom log panel

Opening and Executing your PL/SQL Procedure

The output, in this case, the value of your IN/OUT, X

4 Comments

My version of oracle SQL developer doesn't seem to support this. :(
that feature has existed for years - what version are you running and what happens when you run a SP? inputting the value in the grid for the sp arguments was added in v4 - but you can always edit the anon block
I am using Oracle SQL Developer Version 3.2.20.09
that's how it should work in v3.2 as well. tell me what's not working - or send me an email at [email protected]. or upgrade, takes about 5 minutes to install latest version from OTN
3
DECLARE
  x NUMBER := 6;
BEGIN
  squareOf(x => x );
  dbms_output.put_line( 'X: '|| x );
END;

returns 36

2 Comments

Who gives -1? Why? This is a working answer for this question.
Please accept my excuses, my down-vote was a mistake and I've just undone it (had to make a bogus edit to unlock it).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.