Computer Science, asked by haryanavichhora, 1 month ago

Create a package named as INFO which contains procedure that is passed a student's identification number and return student

Answers

Answered by rk3310602
1

Explanation:

Example 2: How Package Variables Act Across Call Boundaries

This example has both a package specification and package body, which are serially reusable.

CONNECT Scott/Tiger

DROP PACKAGE Sr_pkg;

CREATE OR REPLACE PACKAGE Sr_pkg IS

PRAGMA SERIALLY_REUSABLE;

TYPE Str_table_type IS TABLE OF VARCHAR2(200) INDEX BY BINARY_INTEGER;

Num NUMBER := 10;

Str VARCHAR2(200) := 'default-init-str';

Str_tab STR_TABLE_TYPE;

PROCEDURE Print_pkg;

PROCEDURE Init_and_print_pkg(N NUMBER, V VARCHAR2);

END Sr_pkg;

CREATE OR REPLACE PACKAGE BODY Sr_pkg IS

-- the body is required to have the pragma because the

-- specification of this package has the pragma

PRAGMA SERIALLY_REUSABLE;

PROCEDURE Print_pkg IS

BEGIN

DBMS_OUTPUT.PUT_LINE('num: ' || Sr_pkg.Num);

DBMS_OUTPUT.PUT_LINE('str: ' || Sr_pkg.Str);

DBMS_OUTPUT.PUT_LINE('number of table elems: ' || Sr_pkg.Str_tab.Count);

FOR i IN 1..Sr_pkg.Str_tab.Count LOOP

DBMS_OUTPUT.PUT_LINE(Sr_pkg.Str_tab(i));

END LOOP;

END;

PROCEDURE Init_and_print_pkg(N NUMBER, V VARCHAR2) IS

BEGIN

-- init the package globals

Sr_pkg.Num := N;

Sr_pkg.Str := V;

FOR i IN 1..n LOOP

Sr_pkg.Str_tab(i) := V || ' ' || i;

END LOOP;

-- print the package

Print_pkg;

END;

END Sr_pkg;

SET SERVEROUTPUT ON;

Rem SR package access in a CALL:

BEGIN

-- initialize and print the package

DBMS_OUTPUT.PUT_LINE('Initing and printing pkg state..');

Sr_pkg.Init_and_print_pkg(4, 'abracadabra');

-- print it in the same call to the server.

-- we should see the initialized values.

DBMS_OUTPUT.PUT_LINE('Printing package state in the same CALL...');

Sr_pkg.Print_pkg;

END;

Initing and printing pkg state..

num: 4

str: abracadabra

number of table elems: 4

abracadabra 1

abracadabra 2

abracadabra 3

abracadabra 4

Printing package state in the same CALL...

num: 4

str: abracadabra

number of table elems: 4

abracadabra 1

abracadabra 2

abracadabra 3

abracadabra 4

REM SR package access in subsequent CALL:

BEGIN

-- print the package in the next call to the server.

-- We should that the package state is reset to the initial (default) values.

DBMS_OUTPUT.PUT_LINE('Printing package state in the next CALL...');

Sr_pkg.Print_pkg;

END;

Statement processed.

Printing package state in the next CALL...

num: 10

str: default-init-str

number of table elems: 0

Answered by mauryavijay8088
0

Explanation:

Thx on my answer to complete 3k

Good evening

Similar questions