SlideShare a Scribd company logo
1Using ORACLE®MANIPULATING DATA using PL/SQL
2COMMENTING CODEWe can add comments to the PL/SQL .There are two types of comments:EXAMPLE:	DECLAREeage NUMBER ;	       --This is a single line comment . number variable defined.	BEGIN	SELECT age INTO eage FROM InfoTable WHERE name = ‘bill’;	/* A multiline 			command .Here the select command is defined */	END
3FUNCTIONSThe functions available in SQL can be used in PL/SQL code. Not all SQL function can be used in PL/SQL statements .The SQL functions unavailable in Pl/SQL statements are:DECODE function.All GROUP functions except the LEAST and GREATEST.EXAMPLE1:ename  VARCHAR2(20) := INITCAP(‘bill’); 	--stores Bill in the variable ename.We can use data type conversion function in PL/SQL statements.EXAMPLE 2:mainphone NUMBER(10) := 9000000000;ename VARCHAR2(20);BEGINSELECT name INTO ename FROM InfoTable WHERE phone = TO_NUMBER(mainphone);END
4Operators in PL/SQL
5OperatorsEXAMPLES:profit BOOL;	sp NUMBER;	cp NUMBER;BEGINcp:= 1000;sp:= 1200;profit := ((sp – cp) > 100);      -- finding if profit was above 100 or notEND
6RETRIEVING DATA We can retrieve data using the SELECT command. Variables are used to store the values returned from the SELECT statement and hence have to be of the same datatype and be declared before use.SYNTAX:SELECT column, […column] INTO  variable_name,[…variable_name]FROM table_nameWHERE { expression….};EXAMPLE:DECLAREeage NUMBER;		BEGIN		SELECT age INTO eage FROM InfoTable WHERE name = ‘bill’;	DBMS_OUTPUT.PUT_LINE(‘ Age of bill is : ‘ || eage);		END
7INSERT commandWe can insert data into tables using the PL/SQL INSERT command.SYNTAX:INSERT INTO table_name(column , (…..column))VALUES(value , (…..value));EXAMPLE:BEGIN		INSERT INTO InfoTable		(name,age,phone)		VALUES		(‘micheal’,45,9666002203);		END
8UPDATE commandWe can update data in tables using the PL/SQL UPDATE comand.SYNTAX:UPDATE table_nameSET 	column = value, 	(…column = value);WHERE	{expression };EXAMPLE:	DECLAREeage NUMBER(5):=40;		BEGIN		UPDATE InfoTable SET age = eage		WHERE name =  ‘micheal’;		END
9DELETE commandWe can delete data from tables using the PL/SQL DELETE comand.SYNTAX:DELETE  FROM table_nameWHERE  { expression };EXAMPLE:BEGIN		DELETE  FROM InfoTable		WHERE  age = 45 ;		END
10MERGE COMMANDThe MERGE comand is use to merge the data of one table into the data of another table.The merge command updates or inserts rows in order to make data in both rows similar.DECLAREename INFOTABLE.NAME%TYPE := ‘bill';BEGIN	MERGE INTO addtable a     	USING infotable I					Infotable     	ON (i.name =ename)				   	WHEN MATCHED THEN     	UPDATE SETa.phone = i.phoneADDtable   	WHEN NOT MATCHED THEN     	INSERT VALUES(i.name,NULL,i.phone);		END;ADDtable after MERGE
THANK YOU11THANK YOU FOR VIEWING THIS PRESENTATIONFOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING ,please visit:  www.dataminingtools.net

More Related Content

What's hot (18)

PPT
Les10
arnold 7490
 
PPT
Les09
arnold 7490
 
ODP
My sql Syntax
Reka
 
ODP
Prabu's sql quries
Prabu Cse
 
PPTX
DDL,DML,SQL Functions and Joins
Ashwin Dinoriya
 
PDF
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
PPSX
Oracle Training in Kochi | Trivandrum |Thrissur
IndiaOptions Softwares
 
PDF
Data Definition Language (DDL)
Mohd Tousif
 
PPT
Les12
arnold 7490
 
PPT
Mysql Ppt
Hema Prasanth
 
PPTX
Creating database using sql commands
Belle Wx
 
PDF
SQL Quick Reference Card
Techcanvass
 
PPT
Les14
arnold 7490
 
PPTX
Commands of DML in SQL
Ashish Gaurkhede
 
DOC
Oracle sql material
prathap kumar
 
PDF
Learn plsql
Iulian Avram
 
PPTX
SQL - DML and DDL Commands
Shrija Madhu
 
PPT
Les02
Sudharsan S
 
My sql Syntax
Reka
 
Prabu's sql quries
Prabu Cse
 
DDL,DML,SQL Functions and Joins
Ashwin Dinoriya
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Vidyasagar Mundroy
 
Oracle Training in Kochi | Trivandrum |Thrissur
IndiaOptions Softwares
 
Data Definition Language (DDL)
Mohd Tousif
 
Mysql Ppt
Hema Prasanth
 
Creating database using sql commands
Belle Wx
 
SQL Quick Reference Card
Techcanvass
 
Commands of DML in SQL
Ashish Gaurkhede
 
Oracle sql material
prathap kumar
 
Learn plsql
Iulian Avram
 
SQL - DML and DDL Commands
Shrija Madhu
 

Viewers also liked (16)

PDF
بطاقة وصف تسويق
Asma Al-khaldi
 
PDF
Vitaminas Crescer Com SaúDe
Medusa Fabula
 
PPT
강호동유재석
Webometrics Class
 
PPTX
Projecto Jornalismo
guestf8ccf75
 
PPTX
Derric social media-tactics-gmc
Vasil Azarov
 
PPTX
market strategy
Antony Mazumder
 
PDF
الوصف الوظيفي لوظيفة خدمة العملاء
ثامر عبدالله
 
PPTX
사이버컴과 네트워크분석 6주차 1
Han Woo PARK
 
PPT
Benchmarking tqm
Deborah Sharon
 
PDF
Ayurvedic Treatment For Premature Ejaculation To Increase Sex Duration
Ayush Remedies
 
PPSX
DECEMBER 2016 - Pictures of the month - Dec.̣16 - Dec.21
vinhbinh2010
 
PDF
Learning Deep Learning
simaokasonse
 
PPT
Customer Equity
Yodhia Antariksa
 
PPT
Strategic Planning For Managers
Yodhia Antariksa
 
PDF
تمرانست
Nour Elbader
 
PPT
New Product Development Strategy
Yodhia Antariksa
 
بطاقة وصف تسويق
Asma Al-khaldi
 
Vitaminas Crescer Com SaúDe
Medusa Fabula
 
강호동유재석
Webometrics Class
 
Projecto Jornalismo
guestf8ccf75
 
Derric social media-tactics-gmc
Vasil Azarov
 
market strategy
Antony Mazumder
 
الوصف الوظيفي لوظيفة خدمة العملاء
ثامر عبدالله
 
사이버컴과 네트워크분석 6주차 1
Han Woo PARK
 
Benchmarking tqm
Deborah Sharon
 
Ayurvedic Treatment For Premature Ejaculation To Increase Sex Duration
Ayush Remedies
 
DECEMBER 2016 - Pictures of the month - Dec.̣16 - Dec.21
vinhbinh2010
 
Learning Deep Learning
simaokasonse
 
Customer Equity
Yodhia Antariksa
 
Strategic Planning For Managers
Yodhia Antariksa
 
تمرانست
Nour Elbader
 
New Product Development Strategy
Yodhia Antariksa
 
Ad

Similar to Oracle: Programs (20)

PPT
Plsql
Mandeep Singh
 
PPT
Les18[1]Interacting with the Oracle Server
siavosh kaviani
 
PDF
PL-SQL.pdf
Anas Nakash
 
ODP
Mysqlppt
Reka
 
PPT
Select To Order By
Krizia Capacio
 
PDF
full detailled SQL notesquestion bank (1).pdf
yvpachorib23
 
PPTX
My SQL.pptx
KieveBarreto1
 
PPT
e computer notes - Producing readable output with i sql plus
ecomputernotes
 
PDF
Database Management System
Hitesh Mohapatra
 
DOCX
Exploring collections with example
pranav kumar verma
 
PPTX
Oracle : DML
oracle content
 
PDF
Database development coding standards
Alessandro Baratella
 
PDF
Basic sqlstatements
Anjac
 
PPT
02 Writing Executable Statments
rehaniltifat
 
PPTX
Oracle: Commands
oracle content
 
PPTX
8. sql
khoahuy82
 
PPTX
Function in PL/SQL
Pooja Dixit
 
ODP
Open Gurukul Language PL/SQL
Open Gurukul
 
PDF
SQL on Linux and its uses and application.pdf
bhaveshsethi456
 
PPT
SQl
sarankumarv
 
Les18[1]Interacting with the Oracle Server
siavosh kaviani
 
PL-SQL.pdf
Anas Nakash
 
Mysqlppt
Reka
 
Select To Order By
Krizia Capacio
 
full detailled SQL notesquestion bank (1).pdf
yvpachorib23
 
My SQL.pptx
KieveBarreto1
 
e computer notes - Producing readable output with i sql plus
ecomputernotes
 
Database Management System
Hitesh Mohapatra
 
Exploring collections with example
pranav kumar verma
 
Oracle : DML
oracle content
 
Database development coding standards
Alessandro Baratella
 
Basic sqlstatements
Anjac
 
02 Writing Executable Statments
rehaniltifat
 
Oracle: Commands
oracle content
 
8. sql
khoahuy82
 
Function in PL/SQL
Pooja Dixit
 
Open Gurukul Language PL/SQL
Open Gurukul
 
SQL on Linux and its uses and application.pdf
bhaveshsethi456
 
Ad

More from oracle content (11)

PPTX
Oracle: Procedures
oracle content
 
PPTX
Oracle: PLSQL Introduction
oracle content
 
PPTX
Oracle: Joins
oracle content
 
PPTX
Oracle:Cursors
oracle content
 
PPTX
Oracle: Control Structures
oracle content
 
PPTX
Oracle: Dw Design
oracle content
 
PPTX
Oracle: Basic SQL
oracle content
 
PPTX
Oracle Warehouse
oracle content
 
PPTX
Oracle: Functions
oracle content
 
PPT
Oracle: New Plsql
oracle content
 
PPTX
Oracle: Fundamental Of Dw
oracle content
 
Oracle: Procedures
oracle content
 
Oracle: PLSQL Introduction
oracle content
 
Oracle: Joins
oracle content
 
Oracle:Cursors
oracle content
 
Oracle: Control Structures
oracle content
 
Oracle: Dw Design
oracle content
 
Oracle: Basic SQL
oracle content
 
Oracle Warehouse
oracle content
 
Oracle: Functions
oracle content
 
Oracle: New Plsql
oracle content
 
Oracle: Fundamental Of Dw
oracle content
 

Recently uploaded (20)

PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 

Oracle: Programs

  • 2. 2COMMENTING CODEWe can add comments to the PL/SQL .There are two types of comments:EXAMPLE: DECLAREeage NUMBER ; --This is a single line comment . number variable defined. BEGIN SELECT age INTO eage FROM InfoTable WHERE name = ‘bill’; /* A multiline command .Here the select command is defined */ END
  • 3. 3FUNCTIONSThe functions available in SQL can be used in PL/SQL code. Not all SQL function can be used in PL/SQL statements .The SQL functions unavailable in Pl/SQL statements are:DECODE function.All GROUP functions except the LEAST and GREATEST.EXAMPLE1:ename VARCHAR2(20) := INITCAP(‘bill’); --stores Bill in the variable ename.We can use data type conversion function in PL/SQL statements.EXAMPLE 2:mainphone NUMBER(10) := 9000000000;ename VARCHAR2(20);BEGINSELECT name INTO ename FROM InfoTable WHERE phone = TO_NUMBER(mainphone);END
  • 5. 5OperatorsEXAMPLES:profit BOOL; sp NUMBER; cp NUMBER;BEGINcp:= 1000;sp:= 1200;profit := ((sp – cp) > 100); -- finding if profit was above 100 or notEND
  • 6. 6RETRIEVING DATA We can retrieve data using the SELECT command. Variables are used to store the values returned from the SELECT statement and hence have to be of the same datatype and be declared before use.SYNTAX:SELECT column, […column] INTO variable_name,[…variable_name]FROM table_nameWHERE { expression….};EXAMPLE:DECLAREeage NUMBER; BEGIN SELECT age INTO eage FROM InfoTable WHERE name = ‘bill’; DBMS_OUTPUT.PUT_LINE(‘ Age of bill is : ‘ || eage); END
  • 7. 7INSERT commandWe can insert data into tables using the PL/SQL INSERT command.SYNTAX:INSERT INTO table_name(column , (…..column))VALUES(value , (…..value));EXAMPLE:BEGIN INSERT INTO InfoTable (name,age,phone) VALUES (‘micheal’,45,9666002203); END
  • 8. 8UPDATE commandWe can update data in tables using the PL/SQL UPDATE comand.SYNTAX:UPDATE table_nameSET column = value, (…column = value);WHERE {expression };EXAMPLE: DECLAREeage NUMBER(5):=40; BEGIN UPDATE InfoTable SET age = eage WHERE name = ‘micheal’; END
  • 9. 9DELETE commandWe can delete data from tables using the PL/SQL DELETE comand.SYNTAX:DELETE FROM table_nameWHERE { expression };EXAMPLE:BEGIN DELETE FROM InfoTable WHERE age = 45 ; END
  • 10. 10MERGE COMMANDThe MERGE comand is use to merge the data of one table into the data of another table.The merge command updates or inserts rows in order to make data in both rows similar.DECLAREename INFOTABLE.NAME%TYPE := ‘bill';BEGIN MERGE INTO addtable a USING infotable I Infotable ON (i.name =ename) WHEN MATCHED THEN UPDATE SETa.phone = i.phoneADDtable WHEN NOT MATCHED THEN INSERT VALUES(i.name,NULL,i.phone); END;ADDtable after MERGE
  • 11. THANK YOU11THANK YOU FOR VIEWING THIS PRESENTATIONFOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING ,please visit: www.dataminingtools.net