Skip to content

Instantly share code, notes, and snippets.

View JubbaSmail's full-sized avatar

Jubba Smail JubbaSmail

  • Amsterdam, Netherlands
View GitHub Profile
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';
begin
--cout<<"hello world"<<endl;
dbms_output.put_line('Hello World');
end;
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;
declare
x number;
begin
for i in 0..10 loop
dbms_output.put_line('+'||i);
end loop;
--------------------------
x:=10;
loop
if x < 0 then
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
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;
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
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;
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
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)