0% found this document useful (0 votes)
4 views

Dbms 7 Output

Uploaded by

skw2909
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Dbms 7 Output

Uploaded by

skw2909
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

SQL*Plus: Release 18.0.0.0.

0 - Production on Mon Sep 23 09:33:01 2024


Version 18.4.0.0.0

Copyright (c) 1982, 2018, Oracle. All rights reserved.

Enter user-name: system


Enter password:
Last Successful login time: Mon Sep 23 2024 09:12:14 +05:30

Connected to:
Oracle Database 18c Express Edition Release 18.0.0.0.0 - Production
Version 18.4.0.0.0

1.Create table stud_marks and result.

SQL> Create table Stud_Marks (Roll number Primary Key, Name Varchar2(10),
Total_marks number);

Table created.

SQL> Create table Result (Roll number references Stud_Marks(Roll), Name


Varchar2(10), Class Varchar2(20));

Table created.

SQL> insert into Stud_Marks Values ( 1, 'Ajay', 1100 );

1 row created.

SQL> insert into Stud_Marks Values ( 2, 'Ramesh', 950);

1 row created.

SQL> insert into Stud_Marks Values ( 3, 'Umesh', 850);

1 row created.

SQL> insert into Stud_Marks Values ( 4, 'Suresh', 400);

1 row created.

SQL> select * from stud_marks;

ROLL NAME TOTAL_MARKS


---------- ---------- -----------
1 Ajay 1100
2 Ramesh 950
3 Umesh 850
4 Suresh 400

SQL> select * from result;

no rows selected

SQL> edit proc1.sql

create or replace procedure proc_grade(rno in stud_marks.roll%type, name1 in


stud_marks.name%type) is
totmarks stud_marks.total_marks%type;
grade varchar2(15);
begin
select total_marks into totmarks from stud_marks where roll=rno and
name=name1;
if(totmarks between 825 and 899) then
grade:='secondclass';
insert into result values(rno,name1,grade);
elsif(totmarks between 900 and 989) then
grade:='Firstclass';
insert into result values(rno,name1,grade);
elsif(totmarks between 990 and 1500)then
grade:='Distinction';
insert into result values(rno,name1,grade);
else
dbms_output.put_line('Fail');
end if;
end proc_grade;
/

SQL> @proc1

Procedure created.

SQL> edit p1.sql

declare
result varchar2(15);
totmarks number;
begin
proc_grade(1,'Ajay');
end;
/

SQL> @p1

PL/SQL procedure successfully completed.

SQL> select * from result;

ROLL NAME CLASS


---------- ---------- --------------------
1 Ajay Distinction

You might also like