Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Copyright © 2009, Oracle. All rights reserved. Introducción a PL/SQL.

Similar presentations


Presentation on theme: "1 Copyright © 2009, Oracle. All rights reserved. Introducción a PL/SQL."— Presentation transcript:

1 1 Copyright © 2009, Oracle. All rights reserved. Introducción a PL/SQL

2 Copyright © 2009, Oracle. All rights reserved. 1 - 2 Objetivos Despues de completar esta lección, usted deberá ser capaz de hacer lo siguiente: Explicar la necesidad de PL/SQL Explicar los beneficios de PL/SQL Identificar los diferentes tipo de bloques de PL/SQL Mensajes de salida de PL/PLSQL

3 Copyright © 2009, Oracle. All rights reserved. 1 - 3 Agenda Comprendiendo los beneficios y estructura de PL/SQL structure of PL/SQL Examinar bloques PL/SQL Generando mensajes de salida in PL/SQL

4 Copyright © 2009, Oracle. All rights reserved. 1 - 4 Acerca det PL/SQL PL/SQL: Soporte para “Procedural Language extension to SQL” Es para Oracle un estandar de acceso a datos para base de datos relacionales Integra perfectamente construcción de procedimientos con SQL

5 Copyright © 2009, Oracle. All rights reserved. 1 - 5 Acerca de PL/SQL PL/SQL: Proporciona una estructura de bloque de unidades de codigo ejecutable. El mantenimiento de código es facil con una estructura bien definida. Provides procedural constructs such as: –Variables, constants, and data types –Control structures such as conditional statements and loops –Reusable program units that are written once and executed many times

6 Copyright © 2009, Oracle. All rights reserved. 1 - 6 PL/SQL Run-Time Architecture SQL PL/SQL PL/SQL block procedural Procedural statement executor SQL statement executor Oracle Server PL/SQL Engine

7 Copyright © 2009, Oracle. All rights reserved. 1 - 7 Benefits of PL/SQL Integración de construcciones de procedimientos con SQL. Mejora el rendimiento SQL IF...THEN SQL ELSE SQL END IF; SQL SQL 1 SQL 2 …

8 Copyright © 2009, Oracle. All rights reserved. 1 - 8 Benefits of PL/SQL Programa de desarrollo modularizado Integración con las herramientas de Oracle Portabilidad Manejo de excepciones

9 Copyright © 2009, Oracle. All rights reserved. 1 - 9

10 Copyright © 2009, Oracle. All rights reserved. 1 - 10 PL/SQL Block Structure DECLARE (opcional) –Variables, constantes, cursores, excepciones definidas por el usuario. BEGIN (obligatorio) –Sentencias SQL –Setencias PL/SQL EXCEPTION (optional) –Acciones que se llevarán a cabo al producirse algún error. END ; (obligatorio)

11 Copyright © 2009, Oracle. All rights reserved. 1 - 11

12 Copyright © 2009, Oracle. All rights reserved. 1 - 12 Agenda Comprendiendo los beneficios y estructura de PL/SQL Examinando bloques PL/SQL Generando mensajes de salida de PL/SQL

13 Copyright © 2009, Oracle. All rights reserved. 1 - 13 Tipo de Bloque Procedimientos Funciones Anonimos PROCEDURE name IS BEGIN --statements [EXCEPTION] END; FUNCTION name RETURN datatype IS BEGIN --statements RETURN value; [EXCEPTION] END; [DECLARE] BEGIN --statements [EXCEPTION] END;

14 Copyright © 2009, Oracle. All rights reserved. 1 - 14

15 Copyright © 2009, Oracle. All rights reserved. 1 - 15 Construcción de Programas Application triggers Application packages Application procedures or functions Anonymous blocks Tools Constructs Object types Database triggers Stored packages Stored procedures or functions Anonymous blocks Database Server Constructs Object types

16 Copyright © 2009, Oracle. All rights reserved. 1 - 16

17 Copyright © 2009, Oracle. All rights reserved. 1 - 17 Examinando un Bloque anonimo Un bloque anonimo en el area de trabajo de SQL Developer:

18 Copyright © 2009, Oracle. All rights reserved. 1 - 18 Executiando un bloque Anonimo Click en el botón de Run Script para ejecutar el bloque anonimo: Run Script (or F5)

19 Copyright © 2009, Oracle. All rights reserved. 1 - 19 Agenda Comprendiendo los beneficios y estructura de PL/SQL Examinar bloques PL/SQL Generando mensajes de salida en PL/SQL

20 Copyright © 2009, Oracle. All rights reserved. 1 - 20 Habilitando la salida de bloques PL/SQL Block 1.Para habilitar la salida en SQL Developer, ejecute los siguiente comandos antes de ejecutar el bloque PL/SQL: 2.Use un paquete predefinido en Oracle: – DBMS_OUTPUT.PUT_LINE DBMS_OUTPUT.PUT_LINE( ' The First Name of the Employee is ' || v_fname); … SET SERVEROUTPUT ON

21 Copyright © 2009, Oracle. All rights reserved. 1 - 21 Viewing the Output of a PL/SQL Block Press F5 to execute the command and PL/SQL block.

22 Copyright © 2009, Oracle. All rights reserved. 1 - 22 Quiz A PL/SQL block must consist of the following three sections: A Declarative section, which begins with the keyword DECLARE and ends when the executable section starts. An Executable section, which begins with the keyword BEGIN and ends with END. An Exception handling section, which begins with the keyword EXCEPTION and is nested within the executable section. 1.True 2.False

23 Copyright © 2009, Oracle. All rights reserved. 1 - 23 Summary In this lesson, you should have learned how to: Integrate SQL statements with PL/SQL program constructs Describe the benefits of PL/SQL Differentiate between PL/SQL block types Output messages in PL/SQL

24 Copyright © 2009, Oracle. All rights reserved. 1 - 24 Practice 1: Overview This practice covers the following topics: Identifying the PL/SQL blocks that execute successfully Creating and executing a simple PL/SQL block


Download ppt "1 Copyright © 2009, Oracle. All rights reserved. Introducción a PL/SQL."

Similar presentations


Ads by Google