Sunday, September 6, 2009

Learn Effective pl/sql

Saya coba untuk mengulas mengenai penulisan pl/sql yang effective
berdasarkan referensi yang ada, dan saya tuangkan dalam contoh-contoh pl/sql
dan untuk skripting ini di tulis dengan menggunakan schema SH

declare
cursor c_prod is
select prod_id,
prod_name,
prod_desc,
prod_subcategory
from products
where prod_category_desc = 'Electronics';
rec_prod c_prod%rowtype;
begin
open c_prod;
loop
fetch c_prod into rec_prod;
exit when c_prod%notfound;
dbms_output.put_line('description product '||rec_prod.prod_desc);
end loop;
close c_prod;
end;

declare
v_prod_name products.prod_name%type;
begin
select prod_name
into v_prod_name
from products
where prod_category_desc = 'Electronics'
and prod_id = 300;
if sql%notfound then
dbms_output.put_line('the data not found');
else
dbms_output.put_line('the name of product -> '||v_prod_name);
end if;
exception when no_data_found then
dbms_output.put_line('no data found');
end;

No comments:

Post a Comment