Collections:
Use DML Statements in PL/SQL in Oracle
Can DML Statements Be Used in PL/SQL in Oracle?
✍: FYIcenter.com
Yes, you can run almost any DML statements in PL/SQL directly. To manipulate Oracle database data you can include INSERT, UPDATE, and DELETE statements, directly in PL/SQL programs, without any special notation, as shown in the following sample code:
(Connect to XE with SQL*Plus)
CREATE TABLE student (id NUMBER(5) PRIMARY KEY,
first_name VARCHAR(80) NOT NULL,
last_name VARCHAR(80) NOT NULL);
Table created.
SELECT COUNT(*) FROM student;
COUNT(*)
----------
0
CREATE OR REPLACE PROCEDURE HELLO AS
BEGIN
INSERT INTO student VALUES(29, 'Bob', 'Henry');
INSERT INTO student VALUES(30, 'Joe', 'Bush');
UPDATE student SET first_name = 'Fyi' WHERE id = 30;
DELETE FROM student WHERE id = 29;
END;
/
SELECT * FROM student;
ID FIRST_NAME LAST_NAME
-------- ----------- ----------
30 Fyi Bush
⇒ Cannot Use DDL Statements in PL/SQL in Oracle
⇐ Working with Database Objects in Oracle PL/SQL
2018-10-13, 2485🔥, 0💬
Popular Posts:
How to continue to the next iteration of a WHILE loop in SQL Server Transact-SQL? How to use CONTINU...
What is dba.FYIcenter.com Website about? dba.FYIcenter.com is a Website for DBAs (database administr...
How To Convert Numeric Values to Integers in SQL Server Transact-SQL? Sometimes you need to round a ...
How to calculate the storage size of a JSON (JavaScript Object Notation) value using the JSON_STORAG...
How To Get Year, Month and Day Out of DATETIME Values in SQL Server Transact-SQL? You can use DATEPA...