This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
-- variable_name [CONSTANT] datatype [NOT NULL] | |
x number:=1; | |
emp_hiredate date; | |
emp_deptno number(2) not null := 10; | |
city varchar2(13) := 'Damascus'; | |
xyz constant number := 1400; | |
begin | |
x:=x+1; | |
emp_hiredate:='13-NOV-14'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
--cout<<"hello world"<<endl; | |
dbms_output.put_line('Hello World'); | |
end; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
x number:=4.5; | |
begin | |
if x > 5 then | |
dbms_output.put_line(x || ' is big'); | |
elsif x < 5 then | |
dbms_output.put_line(x || ' is small'); | |
else | |
dbms_output.put_line(x || 'equal 5'); | |
end if; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
x number; | |
begin | |
for i in 0..10 loop | |
dbms_output.put_line('+'||i); | |
end loop; | |
-------------------------- | |
x:=10; | |
loop | |
if x < 0 then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select * from orders | |
--========================================== | |
select order_id,order_mode from orders | |
--========================================== | |
select order_id,order_mode from orders | |
where order_total > 7000 | |
--========================================== | |
select count(order_id) from orders | |
--========================================== | |
select count(order_id) from orders |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
--x varchar(20); | |
x customers.cust_first_name %type; | |
y customers.cust_last_name %type; | |
z customers.gender %type; | |
begin | |
x:='Hello'; | |
select cust_first_name,cust_last_name,gender | |
into x,y,z | |
from customers where customer_id = 205; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
--x varchar(20); | |
x customers %rowtype; | |
begin | |
select * into x | |
from customers | |
where customer_id=200; | |
if x.gender = 'F' then | |
dbms_output.put_line('Ms. ' || x.cust_first_name); | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE | |
CURSOR x IS | |
SELECT cust_first_name,cust_last_name FROM customers; | |
BEGIN | |
FOR y in x loop | |
dbms_output.put_line | |
('The emp name is '|| y.cust_first_name || | |
' ' || y.cust_last_name); | |
END LOOP; | |
END; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
CURSOR x is | |
select cust_first_name,cust_last_name from customers; | |
f_name customers.cust_first_name %type; | |
l_name customers.cust_last_name %type; | |
begin | |
--open | |
open x; | |
--fetch (loop) | |
LOOP |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare | |
CURSOR x(g varchar2 ) is | |
select cust_first_name,cust_last_name from customers | |
where gender=g; | |
f_name customers.cust_first_name %type; | |
l_name customers.cust_last_name %type; | |
begin | |
--open | |
open x('M'); | |
--fetch (loop) |