plsql
plsql
2 a integer :=10;
3 b integer := 20;
4 c integer;
5 f real;
6 BEGin
7 c:=a+b;
8 dbms_output.put_line('Value of c:'||c);
9 f:70.0/3.0;
10 dbms_output.put_line('Value of f:'||f);
11 END;
12 /
f:70.0/3.0;
*
ERROR at line 9:
ORA-06550: line 9, column 2:
PLS-00103: Encountered the symbol "" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "" to continue.
SQL> declare
2 x number(11,2):=10;
3 begin
4 dbms_output.put_line(x);
5 end;
6 /
10
SQL> declare
2 grade CHAR(1);
3 BEGin
4 gradeP:='B'
5 CASE grade
6 WHEN 'A' THEN DBMS_OUTPUT.PUT_LINE('EXCELLENT');
7 WHEN 'B' THEN DBMS_OUTPUT.PUT_LINE('VERY GOOD');
8 WHEN 'C' THEN DBMS_OUTPUT.PUT_LINE('GOOD');
9 WHEN 'D' THEN DBMS_OUTPUT.PUT_LINE('FAIR');
10 WHEN 'F' THEN DBMS_OUTPUT.PUT_LINE('POOR');
11 ELSE THEN DBMS_OUTPUT.PUT_LINE('no such grade');
12 END CASE;
13 END;
14 /
CASE grade
*
ERROR at line 5:
ORA-06550: line 5, column 1:
PLS-00103: Encountered the symbol "CASE" when expecting one of the following:
* & = - + ; < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec between || multiset member submultiset
The symbol "*" was substituted for "CASE" to continue.
ORA-06550: line 6, column 48:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( * % & = - + < / > at else end in is mod remainder not rem
when <an exponent (**)> <> or != or ~= >= <= <> and or like
like2 like4 likec between || multiset member submultiset
The symbol ";" was ignored.
ORA-06550: line 7, column 48:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( * % & = - + < / > at else end in is mod remainder not rem
when <an exponent (**)> <> or != or ~= >= <= <> and or like
like2 like4 likec between || multiset member submultiset
The symbol ";" was ignored.
ORA-06550: line 8, column 43:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( * % & = - + < / > at else end in is mod remainder not rem
when <an exponent (**)> <> or != or ~= >= <= <> and or like
like2 like4 likec between || multiset member submultiset
The symbol ";" was ignored.
ORA-06550: line 9, column 43:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( * % & = - + < / > at else end in is mod remainder not rem
when <an exponent (**)> <> or != or ~= >= <= <> and or like
like2 like4 likec between || multiset member submultiset
The symbol ";" was ignored.
ORA-06550: line 10, column 43:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( * % & = - + < / > at else end in is mod remainder not rem
when <an exponent (**)> <> or != or ~= >= <= <> and or like
like2 like4 likec between || multiset member submultiset
SQL> declare
2 grade CHAR(1);
3 BEGin
4 gradeP:='B'
5 CASE grade
6 WHEN 'A' THEN DBMS_OUTPUT.PUT_LINE('EXCELLENT');
7 WHEN 'B' THEN DBMS_OUTPUT.PUT_LINE('VERY GOOD');
8 WHEN 'C' THEN DBMS_OUTPUT.PUT_LINE('GOOD');
9 WHEN 'D' THEN DBMS_OUTPUT.PUT_LINE('FAIR');
10 WHEN 'F' THEN DBMS_OUTPUT.PUT_LINE('POOR');
11 ELSE DBMS_OUTPUT.PUT_LINE('no such grade');
12 END CASE;
13 END;
14 /
CASE grade
*
ERROR at line 5:
ORA-06550: line 5, column 1:
PLS-00103: Encountered the symbol "CASE" when expecting one of the following:
* & = - + ; < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like like2
like4 likec between || multiset member submultiset
The symbol "*" was substituted for "CASE" to continue.
ORA-06550: line 6, column 48:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( * % & = - + < / > at else end in is mod remainder not rem
when <an exponent (**)> <> or != or ~= >= <= <> and or like
like2 like4 likec between || multiset member submultiset
The symbol ";" was ignored.
ORA-06550: line 7, column 48:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( * % & = - + < / > at else end in is mod remainder not rem
when <an exponent (**)> <> or != or ~= >= <= <> and or like
like2 like4 likec between || multiset member submultiset
The symbol ";" was ignored.
ORA-06550: line 8, column 43:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( * % & = - + < / > at else end in is mod remainder not rem
when <an exponent (**)> <> or != or ~= >= <= <> and or like
like2 like4 likec between || multiset member submultiset
The symbol ";" was ignored.
ORA-06550: line 9, column 43:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( * % & = - + < / > at else end in is mod remainder not rem
when <an exponent (**)> <> or != or ~= >= <= <> and or like
like2 like4 likec between || multiset member submultiset
The symbol ";" was ignored.
ORA-06550: line 10, column 43:
PLS-00103: Encountered the symbol ";" when expecting one of the following:
. ( * % & = - + < / > at else end in is mod remainder not rem
when <an exponent (**)> <> or != or ~= >= <= <> and or like
like2 like4 likec between || multiset member submultiset
The symbol ";" was ignored.
ORA-06550: line 11, column 43:
PLS-00103: Encountered the symbol ";" when expecting one of the follow
SQL> declare
2 grade CHAR(1);
3 BEGin
4 grade:='B';
5 CASE grade
6 WHEN 'A' THEN DBMS_OUTPUT.PUT_LINE('EXCELLENT');
7 WHEN 'B' THEN DBMS_OUTPUT.PUT_LINE('VERY GOOD');
8 WHEN 'C' THEN DBMS_OUTPUT.PUT_LINE('GOOD');
9 WHEN 'D' THEN DBMS_OUTPUT.PUT_LINE('FAIR');
10 WHEN 'F' THEN DBMS_OUTPUT.PUT_LINE('POOR');
11 ELSE DBMS_OUTPUT.PUT_LINE('no such grade');
12 END CASE;
13 END;
14 /
VERY GOOD
SQL> declare
2 p number:=0;
3 begin
4 for k in 1..500 loop --calculate pi for 500 terms
5 p:=p+(((-1)**(k+1))/((2*k)-1));
6 end loop;
7 p:=4*p;
8 dbmsoutput.put_line('pi is approximately : '||p);--print result
9 end;
10 /
dbmsoutput.put_line('pi is approximately : '||p);--print result
*
ERROR at line 8:
ORA-06550: line 8, column 1:
PLS-00201: identifier 'DBMSOUTPUT.PUT_LINE' must be declared
ORA-06550: line 8, column 1:
PL/SQL: Statement ignored
SQL> declare
2 p number:=0;
3 begin
4 for k in 1..500 loop --calculate pi for 500 terms
5 p:=p+(((-1)**(k+1))/((2*k)-1));
6 end loop;
7 p:=4*p;
8 dbms_output.put_line('pi is approximately : '||p);--print result
9 end;
10 /
pi is approximately : 3.13959265558978323858464061338053947907
SQL> declare
2 cursor empcursor is
3 select * from emp;
4 v_empdata empcursor%rowtype;
5 begin
6 open empcursor;
7 loop
8 fetch empcurso into v_empdata;
9 exit when empcursor%notfound;
10 dbms_output.put_line('Recor number: '||empcursor%rowcount||''||
v_empdata.ename);
11 end loop;
12 close empcursor;
13 end;
14 /
fetch empcurso into v_empdata;
*
ERROR at line 8:
ORA-06550: line 8, column 7:
PLS-00201: identifier 'EMPCURSO' must be declared
ORA-06550: line 8, column 1:
PL/SQL: SQL Statement ignored
SQL> declare
2 cursor empcursor is
3 select * from emp;
4 v_empdata empcursor%rowtype;
5 begin
6 open empcursor;
7 loop
8 fetch empcursor into v_empdata;
9 exit when empcursor%notfound;
10 dbms_output.put_line('Recor number: '||empcursor%rowcount||''||
v_empdata.ename);
11 end loop;
12 close empcursor;
13 end;
14 /
Function created.
SQL> declare
2 v_factorial number(4):=0;
3 begin
4 v_factorial:=factorial(5);
5 dbms_output.put_line('The Factorial value : '||v_factorial);
6 end;
7 /
The Factorial value : 120
Function created.