Download presentation
Presentation is loading. Please wait.
Published byAlan Tucker Modified over 9 years ago
1
KKUI Manažérske informačné Systémy Cvičenia 2010 Zdenek Marhefka
2
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
3
KKUI Zdroje informácií Oracle Technology Network http://www.oracle.com/technetwork/index.html − Dokumentácia firmy Oracle − Vývojové prostriedky − Príklady zdrojových kódov, sample data a demá Oracle OLAP http://www.oracle.com/technetwork/database/options/olap/index.html Oracle OLAP option http://wiki.oracle.com/page/Oracle+OLAP+Option Alternatívny zdroj informácií o OLAP v prostredí ORACLE 3
4
KKUI Zdroje informácií Oracle Database 10 g Release 2 (10.2) Documentation http://www.oracle.com/technetwork/database/databas e10g/documentation/index.html V lokálnom adresári: \Mis\oracle10g\index.htm \Mis\oracle10g\index.pdx 4
5
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
6
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
7
KKUI PLSQL – ako to funguje The PL/SQL Engine and the Oracle Database Server: 7
8
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
9
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
10
KKUI Anonymné bloky Structure of PL/SQL-Blocks [ ] [declare ] begin [exception ] end; 10
11
KKUI Uložené procedúry create [or replace] procedure [( )] is begin [exception ] end [ ]; create [or replace] function [( )] return is begin [exception ] end [ ]; 11
12
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
13
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
14
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
15
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
16
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
17
KKUI FOR LOOP FOR loop_counter IN [REVERSE] lowest_number..highest_number LOOP {.statements.} END LOOP; 17
18
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
19
KKUI WHILE LOOP WHILE condition LOOP {.statements.} END LOOP; 19
20
KKUI Repeat Until Loop LOOP {.statements.} EXIT WHEN boolean_condition; END LOOP; 20
21
KKUI 21
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.