SQL> create table product(
2 product_id number(4) not null,
3 product_description varchar2(20) not null
4 );
Table created.
SQL>
SQL> insert into product values (1,'Java');
1 row created.
SQL> insert into product values (2,'Oracle');
1 row created.
SQL> insert into product values (3,'C#');
1 row created.
SQL> insert into product values (4,'Javascript');
1 row created.
SQL> insert into product values (5,'Python');
1 row created.
SQL>
SQL>
SQL> DECLARE
2 v_descr VARCHAR2(20);
3 BEGIN
4 BEGIN
5 SELECT product_description
6 INTO v_descr
7 FROM product
8 WHERE product_id =10;
9 dbms_output.put_line(v_descr);
10 EXCEPTION WHEN NO_DATA_FOUND THEN
11 INSERT INTO product VALUES (10,'Assistant');
12 COMMIT;
13 END;
14 BEGIN
15 SELECT product_description
16 INTO v_descr
17 FROM product
18 WHERE product_id =1;
19 dbms_output.put_line(v_descr);
20 EXCEPTION WHEN NO_DATA_FOUND THEN
21 dbms_output.put_line('ERR:Invalid Data for Hierarchy');
22 END;
23 EXCEPTION
24 WHEN OTHERS THEN
25 dbms_output.put_line('ERR:An error occurred with info :'||
26 TO_CHAR(SQLCODE)||' '||SQLERRM);
27 END;
28 /
Java
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL> drop table product;
Table dropped.
SQL>
|