KKUI Manažérske informačné Systémy Cvičenia 2010 Zdenek Marhefka.

Slides:



Advertisements
Similar presentations
Chapter 8 Advanced SQL Pearson Education © Chapter 8 - Objectives u How to use the SQL programming language u How to use SQL cursors u How to create.
Advertisements

BD05/06 PL/SQL  Introduction  Structure of a block  Variables and types  Accessing the database  Control flow  Cursors  Exceptions  Procedures.
AN INTRODUCTION TO PL/SQL Mehdi Azarmi 1. Introduction PL/SQL is Oracle's procedural language extension to SQL, the non-procedural relational database.
PL/SQL. Introduction to PL/SQL PL/SQL is the procedure extension to Oracle SQL. It is used to access an Oracle database from various environments (e.g.
Murali Mani Persistent Stored Modules (Stored Procedures) : PSM.
PL/SQL (Procedural Language extensions to SQL) Prepared by: Manoj Kathpalia Edited by: M V Ramakrishna.
Lecture-5 Though SQL is the natural language of the DBA, it suffers from various inherent disadvantages, when used as a conventional programming language.
Chapter 4B: More Advanced PL/SQL Programming
3 Copyright © 2004, Oracle. All rights reserved. Creating Packages.
Creating Packages. 2 home back first prev next last What Will I Learn? Describe the reasons for using a package Describe the two components of a package:
Oracle PL/SQL Eyad Husni Elshami. Why PL/SQL Block Structures: – PL/SQL consists of blocks of code, which can be nested within each other. Each block.
Programming in Oracle with PL/SQL
Introduction to PL/SQL
PL/SQL Introduction Database 1. Practice. Sample Database The schema of the sample database is the following: Drinkers (name, occupation, birthday, salary)
Introduction to PL/SQL Chapter 9. Objectives Explain the need for PL/SQL Explain the benefits of PL/SQL Identify the different types of PL/SQL blocks.
Cursors in Pl/SQL Database 1. Practice. Sample Database The schema of the sample database is the following: Drinkers (name, occupation, birthday, salary)
Dr. James Dullea, CSC8490 Introduction to PL/SQLSlide 1 of 36 7From Prof. Dullea CSC8490 Introduction to PL/SQL Module 01-9 Revised: June 12, 2005 Dr.
Introduction to PL/SQL. Procedural Language extension for SQL Oracle Proprietary 3GL Capabilities Integration of SQL Portable within Oracle data bases.
Session Title: Using SQL and PL/SQL for Queries and Reporting Presented By: Stephen Frederic Institution: IHL September 16, 2013.
PL / SQL P rocedural L anguage / S tructured Q uery L anguage Chapter 7 in Lab Reference.
SAGE Computing Services Customised Oracle Training Workshops and Consulting Are you making the most of PL/SQL? Hints and tricks and things you may have.
EE Copyright س Oracle Corporation, All rights reserved. ® Review of PL/SQL.
Lecture 4 PL/SQL language. PL/SQL – procedural SQL Allows combining procedural and SQL code PL/SQL code is compiled, including SQL commands PL/SQL code.
I Copyright © 2004, Oracle. All rights reserved. Introduction Copyright © 2004, Oracle. All rights reserved.
Oracle10g Developer: PL/SQL Programming1 Objectives Programming fundamentals The PL/SQL block Define and declare variables Initialize variables The NOT.
PL/SQLPL/SQL Oracle10g Developer: PL/SQL Programming Chapter 2 Basic PL/SQL Block Structures.
11 Copyright س Oracle Corporation, All rights reserved. ® Overview of PL/SQL.
1 Copyright © 2004, Oracle. All rights reserved. Introduction to PL/SQL.
Stored procedures1 Stored procedures and functions Procedures and functions stored in the database.
Overview · What is PL/SQL · Advantages of PL/SQL · Basic Structure of a PL/SQL Block · Procedure · Function · Anonymous Block · Types of Block · Declaring.
PL SQL Block Structures. What is PL SQL A good way to get acquainted with PL/SQL is to look at a sample program. PL/SQL combines the data manipulating.
Session Title: Using SQL and PL/SQL for Queries and Reporting Presented By: Stephen Frederic Institution: IHL September 16, 2014.
Advanced SQL: Cursors & Stored Procedures
CS178 Database Management PL/SQL session 8 References: ORACLE 9i PROGRAMMING A Primer Rajshekhar Sunderraman.
PL / SQL By Mohammed Baihan. What is PL/SQL? PL/SQL stands for Procedural Language extension of SQL. PL/SQL is a combination of SQL along with the procedural.
PL/SQL Procedural Language / Structured Query Language.
Oracle PL/SQL. PL/SQL Originally modeled after ADA Originally modeled after ADA Created for Dept. of DefenseCreated for Dept. of Defense Allows expanded.
1 Copyright © 2004, Oracle. All rights reserved. Introduction to PL/SQL.
CIS4368: Advanced DatabaseSlide # 1 PL/SQL Dr. Peeter KirsSpring, 2003 PL/SQL.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 8 Advanced SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
PL/SQL Block Structure DECLARE - Optional Variables, cursors, user-defined exceptions BEGIN - Mandatory SQL Statements PL/SQL Statements EXCEPTIONS - Optional.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Database Application Development using PL/SQL Programming.
Database Management COP4540, SCS, FIU Oracle PL/SQL (Ch 10.5)
KKUI Manažérske informačné Systémy Cvičenia 2010 Zdenek Marhefka.
WRITING CONTROL STRUCTURES (CONDITIONAL CONTROL).
What is a Package? A package is an Oracle object, which holds other objects within it. Objects commonly held within a package are procedures, functions,
Chapter 16 Cursors and Exceptions. Chapter Objectives  Determine when an explicit cursor is required  Declare, open, and close an explicit cursor 
implicit and an explicit cursor
Creating Procedures. PL/SQL Program Construct Tools Constructs Anonymous Block Application procedures or functions Application packages Application Triggers.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
Program with PL/SQL Lesson 3. Interacting with the Oracle Server.
Chapter 8 Advanced SQL Pearson Education © Chapter 8 - Objectives How to use the SQL programming language How to use SQL cursors How to create stored.
Creating Functions. Overview of Stored Functions A function is a named PL/SQL block that returns a value. A function is a named PL/SQL block that returns.
PL/SQL  PL/SQL stands for Procedural Language/SQL.  PL/SQL extends SQL by adding constructs found in procedural languages like procedures, loops, variables,
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Overview.
Introduction to PL/SQL N. Dimililer. About PL/SQL –PL/SQL is an extension to SQL with design features of programming languages. –Data manipulation and.
Preface IIntroduction Course Objectives I-2 Oracle Complete Solution I-3 Course Agenda I-4 Tables Used in This Course I-5 The Order Entry Schema I-6 The.
1 Copyright © 2004, Oracle. All rights reserved. PL/SQL Programming Concepts: Review.
PL/pgSQL
PL/SQL.
Oracle11g: PL/SQL Programming Chapter 2 Basic PL/SQL Block Structures.
UNIT - V STORED PROCEDURE.
Introduction to PL/SQL
Chapter 4: Introduction to PL/SQL
Chapter 8 Advanced SQL.
MATERI PL/SQL Procedures Functions Packages Database Triggers
Chapter 8 Advanced SQL Pearson Education © 2009.
© 2014, Mike Murach & Associates, Inc.
Presentation transcript:

KKUI Manažérske informačné Systémy Cvičenia 2010 Zdenek Marhefka

KKUI Obsah cvičení 1. Úvod do databázových systémov 2. Návrh dátového modelu 3. Programovacie jazyky SQL, PLSQL, Java 4. Programovanie v PLSQL 5. Princípy Data Warehousing-u a OLAP 6. Relačná prezentačná vrstva DWH 7. Multidimenzionálna prezentačná vrstva DWH 8. OLAP Spreadsheet Addin 9. Olacle Discoverer 2

KKUI Zdroje informácií  Oracle Technology Network − Dokumentácia firmy Oracle − Vývojové prostriedky − Príklady zdrojových kódov, sample data a demá  Oracle OLAP  Oracle OLAP option Alternatívny zdroj informácií o OLAP v prostredí ORACLE 3

KKUI Zdroje informácií  Oracle Database 10 g Release 2 (10.2) Documentation e10g/documentation/index.html V lokálnom adresári: \Mis\oracle10g\index.htm \Mis\oracle10g\index.pdx 4

KKUI 4 Programovanie v PLSQL 4.1 Úvod do PLSQL 4.2 Programovací jazyk PLSQ  Konštrukcie jazyka  Anonymné bloky  Uložené procedúry  Programové balíky  Príkazy jazyka 4.3 Vytvorenie programového balíka 5

KKUI 4.1 Úvod do PLSQL  PL/SQL (Procedural Language/SQL) is a procedural extension of Oracle- SQL that offers language constructs similar to those in imperative programming languages.  The basic construct in PL/SQL is a block. Blocks allow designers to combine logically related (SQL-) statements into units. In a block, constants and variables can be declared, and variables can be used to store query results. Statements in a PL/SQL block include SQL statements, control structures (loops), condition statements (if-then-else), exception handling, and calls of other PL/SQL blocks.  PL/SQL blocks that specify procedures and functions can be grouped into packages. A package is similar to a module and has an interface and an implementation part. 6

KKUI PLSQL – ako to funguje The PL/SQL Engine and the Oracle Database Server: 7

KKUI PLSQL – ako to funguje The program unit is stored in a database. When an application calls a procedure stored in the database, Oracle loads the compiled program unit into the shared pool in the system global area (SGA). The PL/SQL and SQL statement executors work together to process the statements within the procedure. 8

KKUI Konštrukcie jazyka PL/SQL blocks can include the following PL/SQL language constructs:  Variables and constants Variables and constants can be declared within a procedure, function, or package.  Cursors Cursors can be declared explicitly within a procedure, function, or package to facilitate record-oriented processing of Oracle data. Cursors also can be declared implicitly (to support other data manipulation actions) by the PL/SQL engine.  Exceptions Exceptions PL/SQL lets you explicitly handle internal and user-defined error conditions, called exceptions, that arise during processing of PL/SQL code. 9

KKUI Anonymné bloky Structure of PL/SQL-Blocks [ ] [declare ] begin [exception ] end; 10

KKUI Uložené procedúry create [or replace] procedure [( )] is begin [exception ] end [ ]; create [or replace] function [( )] return is begin [exception ] end [ ]; 11

KKUI Programové balíky create [or replace] package as -- specification (visible part) -- public type and object declarations -- subprogram specifications end [ ]; create [or replace] package body as -- body (hidden part) -- private type and object declarations -- subprogram bodies [ begin -- initialization part starts here ] end [ ]; 12

KKUI Príkazy jazyka  IF-THEN-ELSE  CASE (Oracle 9i, Oracle 10g, Oracle 11g)  LOOP  FOR LOOP  CURSOR FOR LOOP  WHILE LOOP  Repeat Until Loop  EXIT WHEN  NULL 13

KKUI IF-THEN-ELSE Syntax #1: IF-THEN IF condition THEN {...statements...} END IF; Syntax #2: IF-THEN-ELSE IF condition THEN {...statements...} ELSE {...statements...} END IF; Syntax #3: IF-THEN-ELSIF IF condition THEN {...statements...} ELSIF condition THEN {...statements...} ELSE {...statements...} END IF; 14

KKUI CASE CASE [ expression ] WHEN condition_1 THEN result_1 WHEN condition_2 THEN result_2... WHEN condition_n THEN result_n ELSE result END 15

KKUI LOOP LOOP {.statements.} END LOOP; The LOOP statement is terminated when it encounters either an EXIT statement or when it encounters an EXIT WHEN statement that evaluated to TRUE. Example: LOOP monthly_value := daily_value * 31; EXIT WHEN monthly_value > 4000; END LOOP; 16

KKUI FOR LOOP FOR loop_counter IN [REVERSE] lowest_number..highest_number LOOP {.statements.} END LOOP; 17

KKUI CURSOR FOR LOOP FOR record_index in cursor_name LOOP {.statements.} END LOOP; or using SELECT statement FOR record_index in (SELECT FROM WHERE ) LOOP {.statements.} END LOOP; 18

KKUI WHILE LOOP WHILE condition LOOP {.statements.} END LOOP; 19

KKUI Repeat Until Loop LOOP {.statements.} EXIT WHEN boolean_condition; END LOOP; 20

KKUI 21