Compare commits
4 Commits
ad930d8a5a
...
b5cd49389b
Author | SHA1 | Date | |
---|---|---|---|
b5cd49389b | |||
3309645905 | |||
59d480fceb | |||
9318f3069b |
@ -1,8 +1,6 @@
|
|||||||
# P5 - PL-SQL Block
|
# P5 - PL-SQL Block
|
||||||
|
|
||||||
**Problem Statement:** Write a PL/SQL Block to increase the salary of employees by 10% of existing salary, who are having salary less than
|
**Problem Statement:** Write a PL/SQL Block to increase the salary of employees by 10% of existing salary, who are having salary less than average salary of organization, whenever such salary updates take place, a record for same is maintained in the increment_salary table.
|
||||||
average salary of organization, whenever such salary updates take place, a record for same is maintained in the
|
|
||||||
increment_salary table.
|
|
||||||
emp(emp_no, salary)
|
emp(emp_no, salary)
|
||||||
increment_salary(emp_no, salary)
|
increment_salary(emp_no, salary)
|
||||||
|
|
||||||
|
89
Practical/Practical Exam/PL-SQL/P6 - Stored Procedure.md
Normal file
89
Practical/Practical Exam/PL-SQL/P6 - Stored Procedure.md
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
# P6 - Stored Procedure
|
||||||
|
|
||||||
|
**Problem Statement:** Write a Stored Procedure namely proc_Grade for the categorization of student. If marks scored by students in examination is <=1500 and marks>=990 then student will be placed in distinction category if marks scored are between 989 and 900 categories is first class, if marks 899 and 825 category is Higher Second Class. Write a PL/SQL block for using procedure created with above requirement.
|
||||||
|
Stud_Marks(name, total_marks),
|
||||||
|
Result (Roll,Name, Class)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Creating tables
|
||||||
|
```plsql
|
||||||
|
CREATE TABLE Stud_Marks (
|
||||||
|
name VARCHAR2(255),
|
||||||
|
total_marks NUMBER,
|
||||||
|
PRIMARY KEY (name)
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE Result (
|
||||||
|
Roll NUMBER NOT NULL UNIQUE,
|
||||||
|
Name VARCHAR2(255),
|
||||||
|
Class VARCHAR2(255),
|
||||||
|
FOREIGN KEY (Name) REFERENCES Stud_Marks (name)
|
||||||
|
);
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Inserting values
|
||||||
|
```plsql
|
||||||
|
INSERT INTO Stud_Marks VALUES ('Kalas', 1300);
|
||||||
|
INSERT INTO Stud_Marks VALUES ('Himanshu', 800);
|
||||||
|
INSERT INTO Stud_Marks VALUES ('Mehul', 950);
|
||||||
|
INSERT INTO Stud_Marks VALUES ('Gundeti', 875);
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Procedure
|
||||||
|
```plsql
|
||||||
|
CREATE OR REPLACE PROCEDURE proc_Grade (p_roll IN NUMBER, p_name IN VARCHAR2) IS
|
||||||
|
-- declare section
|
||||||
|
marks NUMBER;
|
||||||
|
nodata EXCEPTION;
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
IF (p_name IS NULL) THEN
|
||||||
|
raise nodata;
|
||||||
|
END IF;
|
||||||
|
|
||||||
|
SELECT total_marks INTO marks FROM Stud_Marks WHERE name = p_name;
|
||||||
|
|
||||||
|
IF (marks >= 990 AND marks <= 1500) THEN
|
||||||
|
DBMS_OUTPUT.PUT_LINE(p_name || ' has been placed in the distinction category.');
|
||||||
|
INSERT INTO Result VALUES (p_roll, p_name, 'DISTINCTION');
|
||||||
|
ELSIF (marks BETWEEN 900 AND 989) THEN
|
||||||
|
DBMS_OUTPUT.PUT_LINE(p_name || ' has been placed in the first class category.');
|
||||||
|
INSERT INTO Result VALUES (p_roll, p_name, 'FIRST CLASS');
|
||||||
|
ELSIF (marks BETWEEN 825 AND 899) THEN
|
||||||
|
DBMS_OUTPUT.PUT_LINE(p_name || ' has been placed in the higher second class category.');
|
||||||
|
INSERT INTO Result VALUES (p_roll, p_name, 'HIGHER SECOND CLASS');
|
||||||
|
ELSE
|
||||||
|
DBMS_OUTPUT.PUT_LINE(p_name || ' has failed.');
|
||||||
|
INSERT INTO Result VALUES (p_roll, p_name, 'FAIL');
|
||||||
|
END IF;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN nodata THEN
|
||||||
|
DBMS_OUTPUT.PUT_LINE('Please enter a name');
|
||||||
|
WHEN OTHERS THEN
|
||||||
|
DBMS_OUTPUT.PUT_LINE('Error occurred. Error: ' || SQLERRM);
|
||||||
|
END proc_Grade;
|
||||||
|
/
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
## Calling procedure
|
||||||
|
```plsql
|
||||||
|
DECLARE
|
||||||
|
p_roll NUMBER;
|
||||||
|
p_name VARCHAR2(255);
|
||||||
|
BEGIN
|
||||||
|
DBMS_OUTPUT.PUT_LINE('Enter roll number: ');
|
||||||
|
p_roll := &p_roll;
|
||||||
|
DBMS_OUTPUT.PUT_LINE('Enter name: ');
|
||||||
|
p_name := '&p_name';
|
||||||
|
|
||||||
|
proc_Grade(p_roll, p_name);
|
||||||
|
END;
|
||||||
|
/
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
@ -1 +0,0 @@
|
|||||||
{}
|
|
@ -1 +0,0 @@
|
|||||||
{}
|
|
@ -1,30 +0,0 @@
|
|||||||
{
|
|
||||||
"file-explorer": true,
|
|
||||||
"global-search": true,
|
|
||||||
"switcher": true,
|
|
||||||
"graph": true,
|
|
||||||
"backlink": true,
|
|
||||||
"canvas": true,
|
|
||||||
"outgoing-link": true,
|
|
||||||
"tag-pane": true,
|
|
||||||
"properties": false,
|
|
||||||
"page-preview": true,
|
|
||||||
"daily-notes": true,
|
|
||||||
"templates": true,
|
|
||||||
"note-composer": true,
|
|
||||||
"command-palette": true,
|
|
||||||
"slash-command": false,
|
|
||||||
"editor-status": true,
|
|
||||||
"bookmarks": true,
|
|
||||||
"markdown-importer": false,
|
|
||||||
"zk-prefixer": false,
|
|
||||||
"random-note": false,
|
|
||||||
"outline": true,
|
|
||||||
"word-count": true,
|
|
||||||
"slides": false,
|
|
||||||
"audio-recorder": false,
|
|
||||||
"workspaces": false,
|
|
||||||
"file-recovery": true,
|
|
||||||
"publish": false,
|
|
||||||
"sync": false
|
|
||||||
}
|
|
@ -1,167 +0,0 @@
|
|||||||
{
|
|
||||||
"main": {
|
|
||||||
"id": "deda6ca9cabf39ec",
|
|
||||||
"type": "split",
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"id": "528762701c5cb7c9",
|
|
||||||
"type": "tabs",
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"id": "9e917ff803915418",
|
|
||||||
"type": "leaf",
|
|
||||||
"state": {
|
|
||||||
"type": "markdown",
|
|
||||||
"state": {
|
|
||||||
"file": "S3 - SQL Queries.md",
|
|
||||||
"mode": "source",
|
|
||||||
"source": false
|
|
||||||
},
|
|
||||||
"icon": "lucide-file",
|
|
||||||
"title": "S3 - SQL Queries"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"direction": "vertical"
|
|
||||||
},
|
|
||||||
"left": {
|
|
||||||
"id": "e71c05071f449586",
|
|
||||||
"type": "split",
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"id": "de6e67028318fa69",
|
|
||||||
"type": "tabs",
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"id": "d81d4f98ce4bb78a",
|
|
||||||
"type": "leaf",
|
|
||||||
"state": {
|
|
||||||
"type": "file-explorer",
|
|
||||||
"state": {
|
|
||||||
"sortOrder": "alphabetical"
|
|
||||||
},
|
|
||||||
"icon": "lucide-folder-closed",
|
|
||||||
"title": "Files"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "b53077d766d63e54",
|
|
||||||
"type": "leaf",
|
|
||||||
"state": {
|
|
||||||
"type": "search",
|
|
||||||
"state": {
|
|
||||||
"query": "",
|
|
||||||
"matchingCase": false,
|
|
||||||
"explainSearch": false,
|
|
||||||
"collapseAll": false,
|
|
||||||
"extraContext": false,
|
|
||||||
"sortOrder": "alphabetical"
|
|
||||||
},
|
|
||||||
"icon": "lucide-search",
|
|
||||||
"title": "Search"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "78e9321bb79969d8",
|
|
||||||
"type": "leaf",
|
|
||||||
"state": {
|
|
||||||
"type": "bookmarks",
|
|
||||||
"state": {},
|
|
||||||
"icon": "lucide-bookmark",
|
|
||||||
"title": "Bookmarks"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"direction": "horizontal",
|
|
||||||
"width": 300
|
|
||||||
},
|
|
||||||
"right": {
|
|
||||||
"id": "74524ce0837f7d47",
|
|
||||||
"type": "split",
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"id": "15f80a64187c7b98",
|
|
||||||
"type": "tabs",
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"id": "b56984fac1fac746",
|
|
||||||
"type": "leaf",
|
|
||||||
"state": {
|
|
||||||
"type": "backlink",
|
|
||||||
"state": {
|
|
||||||
"file": "S3 - SQL Queries.md",
|
|
||||||
"collapseAll": false,
|
|
||||||
"extraContext": false,
|
|
||||||
"sortOrder": "alphabetical",
|
|
||||||
"showSearch": false,
|
|
||||||
"searchQuery": "",
|
|
||||||
"backlinkCollapsed": false,
|
|
||||||
"unlinkedCollapsed": true
|
|
||||||
},
|
|
||||||
"icon": "links-coming-in",
|
|
||||||
"title": "Backlinks for S3 - SQL Queries"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "561beefc80815ab4",
|
|
||||||
"type": "leaf",
|
|
||||||
"state": {
|
|
||||||
"type": "outgoing-link",
|
|
||||||
"state": {
|
|
||||||
"file": "S3 - SQL Queries.md",
|
|
||||||
"linksCollapsed": false,
|
|
||||||
"unlinkedCollapsed": true
|
|
||||||
},
|
|
||||||
"icon": "links-going-out",
|
|
||||||
"title": "Outgoing links from S3 - SQL Queries"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "f48d09a595ea27cd",
|
|
||||||
"type": "leaf",
|
|
||||||
"state": {
|
|
||||||
"type": "tag",
|
|
||||||
"state": {
|
|
||||||
"sortOrder": "frequency",
|
|
||||||
"useHierarchy": true
|
|
||||||
},
|
|
||||||
"icon": "lucide-tags",
|
|
||||||
"title": "Tags"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "d43cad33bdc85f3a",
|
|
||||||
"type": "leaf",
|
|
||||||
"state": {
|
|
||||||
"type": "outline",
|
|
||||||
"state": {
|
|
||||||
"file": "S3 - SQL Queries.md"
|
|
||||||
},
|
|
||||||
"icon": "lucide-list",
|
|
||||||
"title": "Outline of S3 - SQL Queries"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"direction": "horizontal",
|
|
||||||
"width": 300,
|
|
||||||
"collapsed": true
|
|
||||||
},
|
|
||||||
"left-ribbon": {
|
|
||||||
"hiddenItems": {
|
|
||||||
"switcher:Open quick switcher": false,
|
|
||||||
"graph:Open graph view": false,
|
|
||||||
"canvas:Create new canvas": false,
|
|
||||||
"daily-notes:Open today's daily note": false,
|
|
||||||
"templates:Insert template": false,
|
|
||||||
"command-palette:Open command palette": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"active": "9e917ff803915418",
|
|
||||||
"lastOpenFiles": []
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user