SlideShare a Scribd company logo
1 of 12
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Introduction to PL SQL Online Training Classes 
info@quontrasolutions.co.uk
WHILE – LOOP - END LOOP 
DECLARE 
… 
v_deptno dept.deptno%TYPE := 50; 
v_counter integer; 
… 
BEGIN 
… 
v_counter := 1; 
WHILE v_counter <= 5 LOOP 
INSERT INTO dept(deptno) 
VALUES(v_deptno); 
v_deptno := v_deptno + 10; 
END LOOP; 
… 
END; 
/
OUTPUT 
SET SERVEROUTPUT ON; 
DECLARE 
v_sum_sal emp.sal%TYPE; 
v_deptno emp.deptno%TYPE := 10; 
BEGIN 
SELECT SUM(sal) 
INTO v_sum_sal 
FROM emp 
WHERE deptno = v_deptno; 
DBMS_OUTPUT.PUT_LINE('The sum is ‘ || TO_CHAR(v_sum_sal)); 
END; 
/
Anonymous Block 
DECLARE 
v_id INTEGER; 
BEGIN 
v_id := 1234567; 
DELETE 
FROM EMP 
WHERE id = v_id; 
EXCEPTION 
WHEN NO_DATA_FOUND THEN 
DBMS_OUTPUT.PUT_LINE('No record exists'); 
END; 
/
Nesting Anonymous Blocks
Exceptions 
Examples are 
NO_DATA_FOUND 
OTHERS 
To display details of oracle standard error 
message 
– EXCEPTION 
• WHEN OTHERS THEN 
DBMS_OUTPUT.PUT_LINE(‘Error detail is: 
‘||SQLERRM)
Procedure 
• Is a block with a name 
• The DECLARE key word is not used 
• Parameters can be 
– IN 
– OUT 
– IN OUT 
• Is stored (USER_SOURCE)
Creating or Replacing a Procedure 
CREATE OR REPLACE PROCEDURE pname( ) IS 
BEGIN 
EXCEPTION 
END; 
/
Creating or Replacing a Procedure 
SET SERVEROUTPUT ON; 
CREATE OR REPLACE PROCEDURE proc_test(p_empno IN VARCHAR2) IS 
v_job EMP.job%TYPE; 
v_sal EMP.sal%TYPE; 
BEGIN 
SELECT job, sal 
INTO v_job,v_sal 
FROM emp 
WHERE empno = p_empno; 
DBMS_OUTPUT.PUT_LINE('job is '||v_job); 
EXCEPTION 
WHEN OTHERS THEN 
DBMS_OUTPUT.PUT_LINE('ERROR...'); 
END; 
/ 
SQL> Show errors 
SQL> execute proc_test(5893);
Invoking a Procedure 
DECLARE 
… 
BEGIN 
… 
proc_test(’23’); 
… 
END; 
/ 
Or 
SQL> exec proc_test(‘1123’)
Another Example 
SQL> ed 
Wrote file afiedt.buf 
1 create or replace procedure test_proc is 
2 v_id INTEGER; 
3 v_empno emp.empno%TYPE; 
4 BEGIN 
5 v_id := 1234567; 
6 select empno into v_empno 
7 FROM EMP 
8 WHERE empno = v_id; 
9 EXCEPTION 
10 WHEN NO_DATA_FOUND THEN 
11 DBMS_OUTPUT.PUT_LINE('No record exists'); 
12* END; 
SQL> / 
Procedure created. 
SQL> exec test_proc 
No record exists 
PL/SQL procedure successfully co.ukpleted. 
SQL> show errors (to see errors for procedures, functions)
www.quontrasolutions.co.uk info@quontrasolutions.co.uk 
Visit: http://www.quontrasolutions.co.uk/ 
Email: info@quontrasolutions.co.uk 
Call Now : (404)-900-9988. (USA) 
info@quontrasolutions.co.uk 
Contd…

More Related Content

More from Quontra Solutions

Oracle-12c Online Training by Quontra Solutions
 Oracle-12c Online Training by Quontra Solutions Oracle-12c Online Training by Quontra Solutions
Oracle-12c Online Training by Quontra SolutionsQuontra Solutions
 
Test Automation Framework Online Training by QuontraSolutions
Test Automation Framework Online Training by QuontraSolutionsTest Automation Framework Online Training by QuontraSolutions
Test Automation Framework Online Training by QuontraSolutionsQuontra Solutions
 
Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsQuontra Solutions
 
Automated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra SolutionsAutomated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra SolutionsQuontra Solutions
 
DataMining and OLAP Technology Concepts Presented By Quontra Solutions
DataMining and OLAP Technology Concepts Presented By Quontra SolutionsDataMining and OLAP Technology Concepts Presented By Quontra Solutions
DataMining and OLAP Technology Concepts Presented By Quontra SolutionsQuontra Solutions
 
Network security by quontra solutions uk
Network security by quontra solutions ukNetwork security by quontra solutions uk
Network security by quontra solutions ukQuontra Solutions
 
Introduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutionsIntroduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutionsQuontra Solutions
 
Informatica Metadata Exchange Frequently Asked Questions by Quontra Solutions
Informatica Metadata Exchange Frequently Asked Questions by Quontra SolutionsInformatica Metadata Exchange Frequently Asked Questions by Quontra Solutions
Informatica Metadata Exchange Frequently Asked Questions by Quontra SolutionsQuontra Solutions
 
Informatica metadata exchange frequently asked questions by quontra solutions
Informatica metadata exchange frequently asked questions by quontra solutionsInformatica metadata exchange frequently asked questions by quontra solutions
Informatica metadata exchange frequently asked questions by quontra solutionsQuontra Solutions
 
Dataware house Introduction By Quontra Solutions
Dataware house Introduction By Quontra SolutionsDataware house Introduction By Quontra Solutions
Dataware house Introduction By Quontra SolutionsQuontra Solutions
 
Selenium overview ppt by quontra solutions
Selenium overview ppt by quontra solutionsSelenium overview ppt by quontra solutions
Selenium overview ppt by quontra solutionsQuontra Solutions
 

More from Quontra Solutions (12)

Oracle-12c Online Training by Quontra Solutions
 Oracle-12c Online Training by Quontra Solutions Oracle-12c Online Training by Quontra Solutions
Oracle-12c Online Training by Quontra Solutions
 
Test Automation Framework Online Training by QuontraSolutions
Test Automation Framework Online Training by QuontraSolutionsTest Automation Framework Online Training by QuontraSolutions
Test Automation Framework Online Training by QuontraSolutions
 
Enterprise java beans
Enterprise java beansEnterprise java beans
Enterprise java beans
 
Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra Solutions
 
Automated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra SolutionsAutomated Software Testing Framework Training by Quontra Solutions
Automated Software Testing Framework Training by Quontra Solutions
 
DataMining and OLAP Technology Concepts Presented By Quontra Solutions
DataMining and OLAP Technology Concepts Presented By Quontra SolutionsDataMining and OLAP Technology Concepts Presented By Quontra Solutions
DataMining and OLAP Technology Concepts Presented By Quontra Solutions
 
Network security by quontra solutions uk
Network security by quontra solutions ukNetwork security by quontra solutions uk
Network security by quontra solutions uk
 
Introduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutionsIntroduction to .net FrameWork by QuontraSolutions
Introduction to .net FrameWork by QuontraSolutions
 
Informatica Metadata Exchange Frequently Asked Questions by Quontra Solutions
Informatica Metadata Exchange Frequently Asked Questions by Quontra SolutionsInformatica Metadata Exchange Frequently Asked Questions by Quontra Solutions
Informatica Metadata Exchange Frequently Asked Questions by Quontra Solutions
 
Informatica metadata exchange frequently asked questions by quontra solutions
Informatica metadata exchange frequently asked questions by quontra solutionsInformatica metadata exchange frequently asked questions by quontra solutions
Informatica metadata exchange frequently asked questions by quontra solutions
 
Dataware house Introduction By Quontra Solutions
Dataware house Introduction By Quontra SolutionsDataware house Introduction By Quontra Solutions
Dataware house Introduction By Quontra Solutions
 
Selenium overview ppt by quontra solutions
Selenium overview ppt by quontra solutionsSelenium overview ppt by quontra solutions
Selenium overview ppt by quontra solutions
 

Recently uploaded

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 

Recently uploaded (20)

Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 

Introduction to pl sql online training classes part 3

  • 1. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Introduction to PL SQL Online Training Classes info@quontrasolutions.co.uk
  • 2. WHILE – LOOP - END LOOP DECLARE … v_deptno dept.deptno%TYPE := 50; v_counter integer; … BEGIN … v_counter := 1; WHILE v_counter <= 5 LOOP INSERT INTO dept(deptno) VALUES(v_deptno); v_deptno := v_deptno + 10; END LOOP; … END; /
  • 3. OUTPUT SET SERVEROUTPUT ON; DECLARE v_sum_sal emp.sal%TYPE; v_deptno emp.deptno%TYPE := 10; BEGIN SELECT SUM(sal) INTO v_sum_sal FROM emp WHERE deptno = v_deptno; DBMS_OUTPUT.PUT_LINE('The sum is ‘ || TO_CHAR(v_sum_sal)); END; /
  • 4. Anonymous Block DECLARE v_id INTEGER; BEGIN v_id := 1234567; DELETE FROM EMP WHERE id = v_id; EXCEPTION WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE('No record exists'); END; /
  • 6. Exceptions Examples are NO_DATA_FOUND OTHERS To display details of oracle standard error message – EXCEPTION • WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE(‘Error detail is: ‘||SQLERRM)
  • 7. Procedure • Is a block with a name • The DECLARE key word is not used • Parameters can be – IN – OUT – IN OUT • Is stored (USER_SOURCE)
  • 8. Creating or Replacing a Procedure CREATE OR REPLACE PROCEDURE pname( ) IS BEGIN EXCEPTION END; /
  • 9. Creating or Replacing a Procedure SET SERVEROUTPUT ON; CREATE OR REPLACE PROCEDURE proc_test(p_empno IN VARCHAR2) IS v_job EMP.job%TYPE; v_sal EMP.sal%TYPE; BEGIN SELECT job, sal INTO v_job,v_sal FROM emp WHERE empno = p_empno; DBMS_OUTPUT.PUT_LINE('job is '||v_job); EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.PUT_LINE('ERROR...'); END; / SQL> Show errors SQL> execute proc_test(5893);
  • 10. Invoking a Procedure DECLARE … BEGIN … proc_test(’23’); … END; / Or SQL> exec proc_test(‘1123’)
  • 11. Another Example SQL> ed Wrote file afiedt.buf 1 create or replace procedure test_proc is 2 v_id INTEGER; 3 v_empno emp.empno%TYPE; 4 BEGIN 5 v_id := 1234567; 6 select empno into v_empno 7 FROM EMP 8 WHERE empno = v_id; 9 EXCEPTION 10 WHEN NO_DATA_FOUND THEN 11 DBMS_OUTPUT.PUT_LINE('No record exists'); 12* END; SQL> / Procedure created. SQL> exec test_proc No record exists PL/SQL procedure successfully co.ukpleted. SQL> show errors (to see errors for procedures, functions)
  • 12. www.quontrasolutions.co.uk info@quontrasolutions.co.uk Visit: http://www.quontrasolutions.co.uk/ Email: info@quontrasolutions.co.uk Call Now : (404)-900-9988. (USA) info@quontrasolutions.co.uk Contd…