Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Databases
  • SQL
  • MySQL
  • PostgreSQL
  • PL/SQL
  • MongoDB
  • SQL Cheat Sheet
  • SQL Interview Questions
  • MySQL Interview Questions
  • PL/SQL Interview Questions
  • Learn SQL and Database
Open In App
Next Article:
Procedures in PL/SQL
Next article icon

Basic Query in PL/SQL procedure

Last Updated : 26 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

PL/SQL (Procedural Language/Structured Query Language) is a powerful extension to SQL, designed to combine the robustness of SQL with procedural constructs like loops, conditions, and more. It plays a crucial role in writing complex database interactions in Oracle databases. This article will cover an overview of PL/SQL, basic query operations, and an in-depth look at parameter modes in PL/SQL subprograms.

What is PL/SQL?

PL/SQL Stands for procedural language extension to SQL. In a procedure, the role of the subprogram is to perform a particular task and it is a unit module of a program. It combined to form larger programs. A subprogram can be involved by another program which is called the calling program. PL/SQL provides a block structure of executable unit code. It provides procedural constructs, for example, in control structure includes loops, conditional statements, and variable, constant, and data type. 

Key Features of PL/SQL

  1. It can be created at the schema level, inside a package, and inside a PL /SQL block. 
  2. The schema-level subprogram is a standalone subprogram. It is created with the CREATE PROCEDURE statement. In the subprogram, it is stored in the database and can be deleted with the DROP PROCEDURE statement. 
  3. It is stored in the database and the package is deleted with the DROP PACKAGE statement. 
  4. PL/SQL provides to kind of subprogram function and procedure.

Function and procedure in PL /SQL

Let’s understand the meaning of function and procedure in PL/SQL:

  1. Function:
    • A function is designed to return a single value.
    • They are often used when you need to compute a value and use it elsewhere in your application.
    • Functions must return a value using the ‘RETURN’ statement.
  2. Procedure: 
    • Procedures perform a specific action but are not required to return a value.
    • They are versatile and can include multiple operations such as inserting, updating, or deleting records in a database.

Creating Procedure in PL/SQL

The ‘CREATE PROCEDURE’ statement is used to define a procedure. You can also use ‘OR REPLACE’ to modify an existing procedure.

Here, we will discuss, how you can create the procedure using PL/SQL query as follows. 

Syntax:

CREATE [ OR REPLACE ] PROCEDURE procedure_name  [( Parameter [ parameter ] ) ]  IS  [ declaration_section ]  BEGIN  executable_section  [ EXCEPTION  exception_section]  END [ procedure_name]; 

Removing procedure in PL/SQL

Once created, a procedure can be removed from the database using the DROP PROCEDURE statement.

Syntax:

DROP PROCEDURE procedure_name; 

Example:

DROP PROCEDURE Update course; 

Parameter modes in PL/ SQL subprograms

Parameter modes define how values are passed to and from the subprogram. There are three parameter modes in PL/SQL:

1. IN Mode

It is read read-only a parameter. IN parameter act like a constant. And within called program or function, It can be referenced. The program cannot assign a new value to the IN parameter. Their value cannot be changed inside the subprogram. 

2. OUT Mode

It is used for getting output from the subprograms. It is a read-write variable inside the subprograms. Their value can be changed inside the subprogram. 

3. IN OUT Mode

To get the input and output from the subprogram then this IN-OUT can be used for getting the results. Their values can be changed inside the subprograms. 

Conclusion

PL/SQL is a versatile and powerful extension to SQL, offering more control and flexibility in writing database programs. Understanding how to perform basic query operations and work with subprograms is fundamental to leveraging the full capabilities of Oracle databases. From creating and removing procedures to effectively using parameter modes, PL/SQL is a key skill for database developers aiming to build scalable, maintainable, and high-performance applications.



Next Article
Procedures in PL/SQL

M

meghawarade04
Improve
Article Tags :
  • PostgreSQL
  • SQL
  • DBMS-SQL

Similar Reads

  • Procedures in PL/SQL
    PL/SQL procedures are reusable code blocks that perform specific actions or logic within a database environment. They consist of two main components such as the procedure header which defines the procedure name and optional parameters and the procedure body which contains the executable statements i
    5 min read
  • Query Processing in SQL
    Query Processing includes translations of high-level Queries into low-level expressions that can be used at the physical level of the file system, query optimization, and actual execution of the query to get the actual result.  High-level queries are converted into low-level expressions during query
    4 min read
  • Query Execution Plan in SQL
    An execution plan in SQL is a detailed plan that outlines the steps that the database management system (DBMS) will take to execute a query. It is a crucial component of query optimization, as it helps the DBMS determine the most efficient way to retrieve data from the database. Here, we will learn
    5 min read
  • How to Drop Procedure in SQL
    In SQL, stored procedures are used to encapsulate complex logic and queries. However, there may come a time when we need to remove or delete a stored procedure from a database. In this article, we will cover the various methods for dropping a stored procedure in SQL along with examples and explanati
    3 min read
  • How to Modify a Stored Procedure in SQL Server?
    In this article, we will learn to modify the created stored procedure in MS SQL.You can modify the Stored Procedure in two ways. one is by using a client called SSMS and other way is by using T-SQL statements + SSMS in MS SQL Server. Method 1: Using SQL Server Management Studio (SSMS) to Modify the
    3 min read
  • SQL Query to Rename Stored Procedure
    Stored Procedure is a saved SQL code. It is created to save time as we can use it again and again without writing the whole query. In this article, we will see how to Rename a Stored Procedure. To create a Procedure:Syntax: CREATE PROCEDURE procedure_name AS SELECT * FROM table_name;SQL query whose
    2 min read
  • Reverse a string in PL/SQL
    Prerequisite - PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Given a string, the task is to reverse a string using P
    1 min read
  • Reverse a number in PL/SQL
    Prerequisite - PL/SQL introduction In PL/SQL code groups of commands are arranged within a block. A block group related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations. Explanation: Consider the example, input = 12345. Step
    2 min read
  • SQL Concepts and Queries
    In this article, we will discuss the overview of SQL and will mainly focus on Concepts and Queries and will understand each with the help of examples. Let's discuss it one by one. Overview :SQL is a computer language that is used for storing, manipulating, and retrieving data in a structured format.
    5 min read
  • PostgreSQL - Introduction to Stored Procedures
    PostgreSQL allows the users to extend the database functionality with the help of user-defined functions and stored procedures through various procedural language elements, which are often referred to as stored procedures.The store procedures define functions for creating triggers or custom aggregat
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences