variable declaration for Oracle in sql developer

Suppose I am in Sql developer and open a new window to perform a sql query. How should I declare a variable? My first line of code below is causing the issue and I don't know why? All I need is to declare a variable on the fly, and then use it. Apparently the Declare statement is not liked by the compiler.


DECLARE MY_NUMBER(10);

SELECT COUNT(1) FROM THE_TABLE;
LVL 2
brgdotnetcontractorAsked:
Who is Participating?
 
Helena MarkováConnect With a Mentor programmer-analystCommented:
declare
MY_NUMBER NUMBER(10);
begin
SELECT COUNT(1) into MY_NUMBER  FROM THE_TABLE;
end;
1
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.