Variables and control statements in PL\SQL Chapter 10.

Slides:



Advertisements
Similar presentations
Creating Tables. 2 home back first prev next last What Will I Learn? List and provide an example of each of the number, character, and date data types.
Advertisements

Basic SQL Introduction Presented by: Madhuri Bhogadi.
Virtual training week 4 structured query language (SQL)
Structured query language This is a presentation by JOSEPH ESTRada on the beauty of Structured Query Language.
A Guide to SQL, Seventh Edition. Objectives Embed SQL commands in PL/SQL programs Retrieve single rows using embedded SQL Update a table using embedded.
Chapter 5 Data Manipulation and Transaction Control Oracle 10g: SQL
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Oracle Data Definition Language (DDL)
SQL Within PL / SQL Chapter 4. 2 SQL Within PL / SQL SQL Statements DML in PL / SQL Pseudocolums Transaction Control.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
CSC 2720 Building Web Applications Database and SQL.
Oracle Data Definition Language (DDL) Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
INTRODUCTION TO PL/SQL. Class Agenda Introduction Introduction to PL/SQL Declaring PL/SQL Variable Creating the Executable Section Interacting with the.
Program with PL/SQL Lesson 5. Working with Composite Data Types.
Overview · What is PL/SQL · Advantages of PL/SQL · Basic Structure of a PL/SQL Block · Procedure · Function · Anonymous Block · Types of Block · Declaring.
Chapter 5: Part 1: DDL STRUCTURED QUERY LANGUAGE (SQL)
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
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.
Trapping Oracle Server Exceptions. 2 home back first prev next last What Will I Learn? Describe and provide an example of an error defined by the Oracle.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
PL/SQL Declaring Variables PL/SQL Block Structure DECLARE (Optional) Variables, cursors, user-defined exceptions BEGIN (Mandatory) - SQL statements -
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 Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
SQL Fundamentals  SQL: Structured Query Language is a simple and powerful language used to create, access, and manipulate data and structure in the database.
SQL. คำสั่ง SQL SQL stands for Structured Query Language is a standard language for accessing and manipulating databases.
1 PL/SQLPL/SQL Declaring Variables Declaring Variables Declaring Variables Declaring Variables Writing Executable Statements Writing Executable Statements.
Tables and Constraints Oracle PL/SQL. Datatypes The SQL Data Definition Language Commands (or DDL) enable us to create, modify and remove database data.
Database Lab Lecture 1. Database Languages Data definition language ( DDL ) Data definition language –defines data types and the relationships among them.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
Database UpdatestMyn1 Database Updates SQL is a complete data manipulation language that can be used for modifying the data in the database as well as.
Cursor FOR Loops. 2 home back first prev next last What Will I Learn? List and explain the benefits of using cursor FOR loops Create PL/SQL code to declare.
Retrieving Data in PL/SQL. 2 home back first prev next last What Will I Learn? In this lesson, you will learn to: –Recognize the SQL statements that can.
Variables and Constants Objectives F To understand Identifiers, Variables, and Constants.
implicit and an explicit cursor
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
Declaring PL/SQL Variables
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
Lab 2 Writing PL/SQL Blocks CISB514 Advanced Database Systems.
Chapter 3 Table Creation and Management Oracle 10g: SQL.
Oracle 10g Retrieving Data Using the SQL SELECT Statement.
1 Copyright © 2009, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement.
Oracle 11g: SQL Chapter 5 Data Manipulation and Transaction Control.
A Guide to SQL, Seventh Edition
Interacting with the Oracle Server
SQL Creating and Managing Tables
Interacting with the Oracle Server
Database Management Systems 2
SQL Creating and Managing Tables
STRUCTURED QUERY LANGUAGE
Database.
SQL Creating and Managing Tables
Unit-1 Introduction to Java
variables and control statements in PL\SQL
Chapter 2 Views.
Oracle Data Definition Language (DDL)
SQL .. An overview lecture3.
Chapter 2 Views.
Chapter 8 Advanced SQL.
Using SQL*Plus.
PL/SQL Declaring Variables.
Database SQL.
C Programming Lecture-3 Keywords, Datatypes, Constants & Variables
SQL (Structured Query Language)
Presentation transcript:

variables and control statements in PL\SQL Chapter 10

Use of Variables Temporary storage: You can use the value stored in these variables for processing and manipulating the data Variables are mainly used for storage of data and manipulation of stored values. Consider the SQL statement shown in the slide. The statement retrieves the first_name and department_id from the table. If you have to manipulate the first_name or the department_id, then you have to store the retrieved value. Reusability is another advantage of declaring variables. After they are declared, variables can be used repeatedly in an application by referring to them in the statements.

Identifiers Identifiers are used for: 1. Naming a variable 2. Providing conventions for variable names – Must start with a letter – Can include letters or numbers – Can include special characters (such as dollar sign, underscore, and pound sign) – Must limit the length to 30 characters – Must not be reserved words

Guidelines for Declaring PL/SQL Variables Impose the NOT NULL constraint when the variable must contain a value. You cannot assign nulls to a variable defined as NOT NULL. The NOT NULL constraint must be followed by an initialization clause. – pincode NUMBER(15) NOT NULL := 'Oxford';

Data Types

%TYPE Attribute The %TYPE attribute Is used to declare a variable according to: – A database column definition – Another declared variable Is prefixed with: – The database table and column – The name of the declared variable

SQL Statements in PL/SQL PL/SQL does not directly support data definition language (DDL) statements, such as CREATE TABLE, ALTER TABLE, or DROP TABLE Use the EXECUTE IMMEDIATE statement, which takes the SQL statement as an argument to execute your DDL statement.

Guidelines for Retrieving Data in PL/SQL Terminate each SQL statement with a semicolon ( ; ). Every value retrieved must be stored in a variable using the INTO clause. The WHERE clause is optional and can be used to specify input variables, constants, literals, and PL/SQL expressions. However, when you use the INTO clause, you should fetch only one row; using the WHERE clause is required in such cases. Specify the same number of variables in the INTO clause as the number of database columns in the SELECT clause. Be sure that they correspond appositionally and that their data types are compatible.