Logo

Navigation
  • Home
  • Services
    • ERP Solutions
    • Implementation Solutions
    • Support and Maintenance Solutions
    • Custom Solutions
    • Upgrade Solutions
    • Training and Mentoring
    • Web Solutions
    • Production Support
    • Architecture Designing
    • Independent Validation and Testing Services
    • Infrastructure Management
  • Expertise
    • Microsoft Development Expertise
    • Mobile Development
    • SQL Server Database and BI
    • SAP BI, SAP Hana, SAP BO
    • Oracle and BI
    • Oracle RAC
  • Technical Training
    • Learn Data Management
      • Business Intelligence
      • Data Mining
      • Data Modeling
      • Data Warehousing
      • Disaster Recovery
    • Learn Concepts
      • Application Development
      • Client Server
      • Cloud Computing Tutorials
      • Cluster Computing
      • CRM Tutorial
      • EDI Tutorials
      • ERP Tutorials
      • NLP
      • OOPS
      • Concepts
      • SOA Tutorial
      • Supply Chain
      • Technology Trends
      • UML
      • Virtualization
      • Web 2.0
    • Learn Java
      • JavaScript Tutorial
      • JSP Tutorials
      • J2EE
    • Learn Microsoft
      • MSAS
      • ASP.NET
      • ASP.NET 2.0
      • C Sharp
      • MS Project Training
      • Silverlight
      • SQL Server 2005
      • VB.NET 2005
    • Learn Networking
      • Networking
      • Wireless
    • Learn Oracle
      • Oracle 10g
      • PL/SQL
      • Oracle 11g Tutorials
      • Oracle 9i
      • Oracle Apps
    • Learn Programming
      • Ajax Tutorial
      • C Language
      • C++ Tutorials
      • CSS Tutorial
      • CSS3 Tutorial
      • JavaScript Tutorial
      • jQuery Tutorial
      • MainFrame
      • PHP Tutorial
      • VBScript Tutorial
      • XML Tutorial
    • Learn Software Testing
      • Software Testing Types
      • SQA
      • Testing
  • Career Training
    • Career Improvement
      • Career Articles
      • Certification Articles
      • Conflict Management
      • Core Skills
      • Decision Making
      • Entrepreneurship
      • Goal Setting
      • Life Skills
      • Performance Development
      • Personal Excellence
      • Personality Development
      • Problem Solving
      • Relationship Management
      • Self Confidence
      • Self Supervision
      • Social Networking
      • Strategic Planning
      • Time Management
    • Education Help
      • Career Tracks
      • Essay Writing
      • Internship Tips
      • Online Education
      • Scholarships
      • Student Loans
    • Managerial Skills
      • Business Communication
      • Business Networking
      • Facilitator Skills
      • Managing Change
      • Marketing Management
      • Meeting Management
      • Process Management
      • Project Management
      • Project Management Life Cycle
      • Project Management Process
      • Project Risk Management
      • Relationship Management
      • Task Management
      • Team Building
      • Virtual Team Management
    • Essential Life Skills
      • Anger Management
      • Anxiety Management
      • Attitude Development
      • Coaching and Mentoring
      • Emotional Intelligence
      • Stress Management
      • Positive Thinking
    • Communication Skills
      • Conversation Skills
      • Cross Culture Competence
      • English Vocabulary
      • Listening Skills
      • Public Speaking Skills
      • Questioning Skills
    • Soft Skills
      • Assertive Skills
      • Influence Skills
      • Leadership Skills
      • Memory Skills
      • People Skills
      • Presentation Skills
    • Finding a Job
      • Etiquette Tips
      • Group Discussions
      • HR Interviews
      • Interview Notes
      • Job Search Tips
      • Resume Tips
      • Sample Resumes
 

Building PL/SQL Blocks in Oracle 9i

By Exforsys | on February 16, 2005 |
Oracle 9i
This Week we will be learning about Creating PL/SQL Blocks which includes Declaration Section, Variables, Scope of Variables, Constants Records, Manipulating Data in PL/SQL and Using DML in PL/SQL .

PL/SQL is a procedural extension for Oracle’s Structured Query Language. PL/SQL is not a separate language rather a technology. Mean to say that you will not have a separate place or prompt for executing your PL/SQL programs. PL/SQL technology is like an engine that executes PL/SQL blocks and subprograms. This engine can be started in Oracle server or in application development tools such as Oracle Forms, Oracle Reports etc.

As shown in the above figure PL/SQL engine executes procedural statements and sends SQL part of statements to SQL statement processor in the Oracle server. PL/SQL combines the data manipulating power of SQL with the data processing power of procedural languages.

Block Structure of PL/SQL: PL/SQL is a block-structured language. i.e. Programs of PL/SQL contain logical blocks.

As shown in the Fig.2 a PL/SQL block has three parts.

1) Declaration: Necessary variables are declared in this section. (Optional)

2) Begin: This section contain executable statements of SQL and PL/SQL

3) Exception: Any error occurred while executing the statements in begin part can be handled in this part.

Variables and Constants: Variables are used to store query results. Forward references are not allowed. Hence you must first declare the variable and then use it.


Variables can have any SQL datatype, such as CHAR, DATE, NUMBER etc or any PL/SQL datatype like BOOLEAN, BINARY_INTEGER etc.

Declaring Variables: Variables are declared in DECLARE section of PL/SQL.

DECLARE
SNO NUMBER (3);
SNAME VARCHAR2 (15);
_ _ _
BEGIN

Assigning values to variables:

SNO NUMBER : = 1001; or SNAME := ‘JOHN’; etc

Following screen shot explain you how to write a simple PL/SQL program and execute it.

 


SET SERVEROUTPUT ON is a command used to access results from Oracle Server.
A PL/SQL program is terminated by a “ / “. DBMS_OUTPUT is a package and PUT_LINE is a procedure in it. You will learn more about procedures, functions and packages in the following sections of this tutorial.

Above program can also be written as a text file in Notepad editor and then executed as explained in the following screen shot.

 

 

SET SERVEROUTPUT ON is a command used to access results from Oracle Server.
A PL/SQL program is terminated by a “ / “. DBMS_OUTPUT is a package and PUT_LINE is a procedure in it. You will learn more about procedures, functions and packages in the following sections of this tutorial.

Above program can also be written as a text file in Notepad editor and then executed as explained in the following screen shot.

 

SET SERVEROUTPUT ON is a command used to access results from Oracle Server.
A PL/SQL program is terminated by a “ / “. DBMS_OUTPUT is a package and PUT_LINE is a procedure in it. You will learn more about procedures, functions and packages in the following sections of this tutorial.

Above program can also be written as a text file in Notepad editor and then executed as explained in the following screen shot.

 

 

 

 

 

SQL > / 
Welcome To PL/SQL Programming

PL/SQL procedure successfully completed.

Scope and Visibility of Variables : An identifier in PL/SQL block is considered as local to that block and global to all its Sub-blocks. Which is better understood from the following example.


There are 2 composite datatypes. TABLE and

RECORD. Objects of type RECORD are called records. Objects of type TABLE are called PL/SQL table.

User-Defined Records: The %rowtype attribute can be used to store a record fetched from the table. But it is not possible to declare datatype for the fields in %rowtype. This problem is solved in the object type RECORD. The usage of %rowtype and RECORD object are explained below.



PL/SQL Tables:

PL/SQL tables are modeled as database tables but are not same as database tables. 
The size of a PL/SQL table is unconstrained i.e. it can grow dynamically whenever a new 
record is added.  Its size is constrained only by the available memory. Every PL/SQL table 
will have a primary  key column of BINARY_INTEGER type. 
 
 
		
	
« « More Oracle 9i Database Objects
ASP.NET with C# Training Launch » »

Author Description

Avatar

Editorial Team at Exforsys is a team of IT Consulting and Training team led by Chandra Vennapoosa.

Free Training

RSSSubscribe 394 Followers
  • Popular
  • Recent
  • Download example SQL Scripts used in Oracle 9i Tutorials

    March 3, 2005 - 0 Comment
  • Oracle 9i Exception Handling

    March 3, 2005 - 0 Comment
  • Oracle 9i PL/SQL Collections

    March 6, 2005 - 0 Comment
  • Oracle 9i Procedures and Functions

    March 13, 2005 - 0 Comment
  • Oracle 9i Database Triggers

    March 28, 2005 - 0 Comment
  • Oracle 9i Packages

    April 7, 2005 - 0 Comment
  • Oracle 9i Utilities

    April 30, 2005 - 0 Comment
  • Oracle 9i Tables and Constraints

    February 2, 2005 - 0 Comment
  • Introduction to Oracle 9i SQL, PLSQL, and SQL *Plus

    October 24, 2004 - 0 Comment
  • More Oracle 9i Database Objects

    February 14, 2005 - 0 Comment
  • Oracle 9i Utilities

    April 30, 2005 - 0 Comment
  • Oracle 9i Packages

    April 7, 2005 - 0 Comment
  • Oracle 9i Database Triggers

    March 28, 2005 - 0 Comment
  • Oracle 9i Procedures and Functions

    March 13, 2005 - 0 Comment
  • Oracle 9i PL/SQL Collections

    March 6, 2005 - 0 Comment
  • Oracle 9i Exception Handling

    March 3, 2005 - 0 Comment
  • Download example SQL Scripts used in Oracle 9i Tutorials

    March 3, 2005 - 0 Comment
  • Oracle 9i Cursors

    February 27, 2005 - 0 Comment
  • Oracle 9i PL/SQL Control Structures

    February 26, 2005 - 0 Comment
  • More Oracle 9i Database Objects

    February 14, 2005 - 0 Comment

Exforsys e-Newsletter

ebook
 

Related Articles

  • Oracle 9i Utilities
  • Oracle 9i Packages
  • Oracle 9i Database Triggers
  • Oracle 9i Procedures and Functions
  • Oracle 9i PL/SQL Collections

Latest Articles

  • Project Management Techniques
  • Product Development Best Practices
  • Importance of Quality Data Management
  • How to Maximize Quality Assurance
  • Utilizing Effective Quality Assurance Strategies
  • Sitemap
  • Privacy Policy
  • DMCA
  • Trademark Information
  • Contact Us
© 2023. All Rights Reserved.IT Training and Consulting
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish.AcceptReject Read More
Privacy & Cookies Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT