0% found this document useful (0 votes)
35 views4 pages

Create A Package Named As INFO

The document details creating tables and packages in Oracle to retrieve student information from a student table based on ID, and check if a department number exists in another table, returning true or false. It provides code to create the tables and packages, call the procedures, and output the results.

Uploaded by

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

Create A Package Named As INFO

The document details creating tables and packages in Oracle to retrieve student information from a student table based on ID, and check if a department number exists in another table, returning true or false. It provides code to create the tables and packages, call the procedures, and output the results.

Uploaded by

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

Create a package named as INFO which contains

procedure that is passed a student’s identification


number and return student’s full name and phone
number from the student table to the calling
program and function, pass a department number
to it. If the DEPT table does not contain the
department number, return a FALSE value otherwise return a TRUE value. Print the appropriate
message to the calling program.

CODE:

CREATE TABLE student (ID INTEGER,FNAME VARCHAR(20),LNAME VARCHAR(20),GENDER CHAR(1),dept


number(20),p_no number(10));

INSERT INTO student VALUES(101,'ROHIT','SINGH','M',20,9867543210);

INSERT INTO student VALUES(102,'VISHAL','PANDEY','M',21,8998899809);

INSERT INTO student VALUES(103,'PIHU','KUMARI','M',22,9080706050);

INSERT INTO student VALUES(104,'RAHUL','SINHA','F',23,9192939495);

INSERT INTO student VALUES(105,'HARRY','POTTER','M',24,8765432198);

--DROP TABLE student

CREATE OR REPLACE PACKAGE stu AS

PROCEDURE stu_info(s_id student.id%type);

END stu;

--------------------------------------------------

CREATE OR REPLACE PACKAGE BODY stu AS


PROCEDURE stu_info(s_id student.id%type) IS

s_fname student.fname%TYPE;

s_p_no student.p_no%TYPE;

BEGIN

SELECT fname INTO s_fname

FROM student

WHERE id = s_id;

dbms_output.put_line('NAME : '|| s_fname);

SELECT p_no INTO s_p_no

FROM student

WHERE id = s_id;

dbms_output.put_line('PHONE NO : '|| s_p_no);

END stu_info;

END stu;

----------------find department exist or not------------------------------

CREATE OR REPLACE PACKAGE stu1 AS

PROCEDURE stu_dept(s_dept student.dept%type);

END stu1;
---------package body-----------------

CREATE OR REPLACE PACKAGE BODY stu1 AS

PROCEDURE stu_dept(s_dept student.dept%type) IS

s_fname student.fname%TYPE;

BEGIN

if s_dept=10 then

dbms_output.put_line('TRUE ');

else

dbms_output.put_line(' FALSE ');

end if;

END stu_dept;

END stu1;

-----------------student info------------------------------------

declare

sid number;

begin

sid:=102;
stu.stu_info(sid);

end;

-----------department----------

declare

sdept number;

begin

sdept:=20;

stu1.stu_dept(sdept);

end;

OUTPUT:

You might also like