Upload
others
View
4
Download
0
Embed Size (px)
Citation preview
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Mehr als Report on Table APEX präsentiert Daten aller Art – in der Cloud
Carsten Czarski Consulting Member of technical Staff – Oracle Application Express Oracle Deutschland B.V. & Co KG
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Oracle Application Express (Oracle APEX) • Anwendungsentwicklung im Browser
– Desktop- und Mobile Applications
– Responsive Layouts: "State Of the Art"
• Bestandteil der Oracle-Datenbank
– Oracle Enterprise Edition
– Oracle Standard Edition/ Standard Edition One
– Oracle XE
• Supported Database Releases
– 10gR2, 11gR1 and 11gR2, 12c
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Application Express: Architektur
• APEX-Engine läuft in der Datenbank
– Seiten-Processing und Rendering
– Webserver übernimmt nur Kommunikation
• Nutzung aller Datenbankfunktionen
– Spatial, XML, JSON, Multimedia, PL/SQL
– Backup & Recovery, HA, Parallel, In-Memory
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
APEX ist metadatengetrieben
• APEX implementiert ein "Datenmodell für Anwendungen"
– Alle Bestandteile einer Anwendung werden in Tabellen gespeichert
– Bearbeiten der Anwendung mit APEX Application Builder
– Rendering der Seiten anhand Metadaten
– Anwendungs-Data Dictionary stellt alle Informationen in Views bereit
• Sehr mächtige Architektur
– Keine Code-Generierung – alles kann jederzeit geändert werden
– Strukturierter Zugriff auf alle Anwendungsbestandteile
– QA auf völlig neuem Niveau: Suchen in Anwendungen mit SQL!
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Daten in APEX-Anwendungen - klassisch
APEX-Datenbank Lokale Tabellen
Entfernte Tabellen Via Database Link
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Daten in APEX-Anwendungen - Anforderungen
APEX-Datenbank Lokale Tabellen
Oracle-Datenbank In der Cloud
Oracle-Datenbank Im Unternehmen
Andere Daten In der Cloud
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Ein Lösungsansatz: REST Architekturen
• REST Services haben viele Vorteile – Netzwerkkommunikation sehr einfach, da auf dem HTTP-Protokoll basiert
– REST Standard erlaubt lose Kopplung mit anderen Systemen (on Premise oder Cloud)
– SQL*Net Freigabe über Public Internet oft problematisch
• Oracle Database as a Service ist bereits REST Enabled – ORDS zur Bereitstellung eigener REST-Services vorinstalliert
– REST Services können mit APEX oder PL/SQL bereitgestellt werden
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Externe Daten via REST
APEX-Datenbank Lokale Tabellen
RE
ST
via
HT
TP
(s)
Externe Datenquellen
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
REST Webservices: Was ist das?
• REST: Representational State Transfer
• Einfache Architektur – Ressoucen
– Methoden
– Repräsentationen
• Stateless leicht skalierbar!
• HTTP (Internet) folgt diesem Konzept
Ressourcen: URL
Methoden GET, POST,
PUT, DELETE
Representations Mime-Types
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Eine REST-Definition: Ein Beispiel
• REST-Interface für Tabellen – POST lädt eine neue Datei hoch
– PUT aktualisiert eine Datei
– GET listet alle Dateien
– GET ruft eine einzelne Datei ab
– DELETE löscht eine Datei
• REST Schnittstelle abstrahiert von der konkreten Implementierung
GET /documents
GET /documents/:id
PUT /documents/:id
POST /documents
DELETE /documents/:id
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Einfacher REST Service im Internet: USGS Earthquake
http://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Externe REST Services in APEX nutzen
• Application Express und die Datenbank bringen alles Nötige mit – HTTP-Zugriffe mit UTL_HTTP oder APEX_WEB_SERVICE
– Web Service References in Application Express
– XML-Verarbeitung mit den SQL/XML Funktionen
– JSON-Verarbeitung mit SQL/JSON Funktionen
• Für das Earthquake-Beispiel – Abrufen der JSON-Daten mit APEX_WEB_SERVICE
– JSON Parsing mit SQL/JSON Funktionen
– Bereitstellen der Ergebnisse als SQL Result Set
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Native JSON Unterstützung in Oracle12c
JSON speichern und verwalten • JSON als Text in Tabellen (VARCHAR2, CLOB, BLOB) ablegen Schemalose Daten – volle Flexibilität
• Kein spezieller Datentyp – alle bestehenden Anwendungen und Werkzeuge können die Funktionen nutzen
API und SQL-Funktionen zum Zugriff JSON_VALUE
JSON_QUERY
JSON_EXISTS
JSON_TABLE
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Einfacher REST Service im Internet: USGS Earthquake
• REST Daten meist als JSON
• Listen als JSON-Array
• Zeilen als Array-Elemente
• Spalten als Attribute
• Mit SQL sehr einfach konsumierbar!
http://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
USGS Earthquake: JSON abrufen und parsen – mit SQL!
02/09/2014
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Ergebnis der SQL-Query
02/09/2014
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Moment mal ...
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Mit SQL ...
• APEX_WEB_SERVICE: – Zugriff auf REST Service
– Abrufen der JSON Daten
• JSON_TABLE-Funktion – Parsing der JSON Daten
– Ergebnis als SQL-Tabelle auf
02/09/2014
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Der REST Service steht als "Tabelle" bereit!
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Darstellen in Application Express – als Bericht
02/09/2014
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Darstellen in Application Express – als Kalender
02/09/2014
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Darstellen in Application Express – als Karte
02/09/2014
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
REST Services in der Praxis ...
• Query-Filter – Abrufen aller Daten und dann SQL Filtering oft nicht sinnvoll
– Query-Filter müssen an den REST Service gesendet werden (URL-Parameter)
– Vorsicht mit APEX Interactive Reports
• Viele REST Services liefern Ergebnisse seitenweise aus – Grund: Skalierbarkeit – keine zu großen Datenmengen ausliefern
– Zum Abrufen aller Daten ist ein Paging nötig: Alle "Seiten" müssen abgeholt werden
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
Query Filter an den REST Service übergeben
Copyright © 2014 Oracle and/or its affiliates. All rights reserved. |
[email protected] http://tinyurl.com/apexcommunity http://sql-plsql-de.blogspot.com http://plsqlexecoscomm.sourceforge.net http://plsqlmailclient.sourceforge.net Twitter: @cczarski @oraclebudb