I'm trying to define variables in a .sql file so that I can use them in my sql statments. But I'm so confused about how these variables are defined, and I can't find even one good online resource that has explained all this in clear manner. I follow the recommendations in different sources and I keep getting compile errors in 'Oracle SQL Developer'. Here are my 2 problems:
Problem 1: It seems that you can define variables in the following 2 ways. What is the difference between these 2 ways, and can I use both?
define first_name = Joe;
select * from customer where name = '&firstname';
or
variable first_name CHAR;
exec :first_name:= 'Joe';
select * from customer where name = :firstname;
Problem 2: In the first method (meaning using define command), can I define a variable of type number and if so, how can I do it?