2

I am new to PL/SQL, I'm trying to execute the commands that I learned at the course.

VARIABLE area NUMBER
DECLARE
  radius NUMBER(2) := &s_radius;
  pi CONSTANT NUMBER := 3.14;
BEGIN
  :area := pi * radius * radius;
END;

I understand that I can run this using SqlPlus, but I remember my teacher was running this from the web browser using Application Express. I try to run the same commands there, at HOME >SQL>SQL Commands, but I keep getting the error

"ORA-00900: invalid SQL statement"

.
Can you help me run it in Application Express or point me to a way where I can use an editor to run these course exercises?
Thanks!

1 Answer 1

2

Apex does not use variables the same way, since it does not really run SQLPlus (it looks pretty similar though). It sounds like the examples you have from class are all intended to be used in the command line version -- not the browser version. Therefore, area and s_radius won't be known.

However, you can deal with that by rewriting your example:

DECLARE
  area NUMBER;
  radius NUMBER(2) := 4; -- I have no idea what value you used.
  pi CONSTANT NUMBER := 3.14;
BEGIN
  area := pi * radius * radius;
  dbms_output.put_line ('Area is ' || area);
END;
Sign up to request clarification or add additional context in comments.

Comments

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.