Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews DB Oracle Interviews:Concepts and ArchitectureData AccessDatabase ArchitectureDatabase ManagementDatabase Security OracleDistributed ProcessingFlexfieldForms ReportsGeneral OracleMemory ManagementMTO-SAP Financial AccountingOCIOracle AOLOracle AROracle Backup RecoveryOracle D2KOracle DatabaseOracle Database DeveloperOracle DB OptimizationOracle DBAOracle DeveloperOracle ETLOracle Forms 3.0Oracle Forms 4.0Oracle GLOracle PL-SQLOracle RMANOracle ScenariosOracle SecurityOracle SQLOracle System ArchitectureOracle Technology Network (OTN)Programmatic ConstructsRAC (Real Application Clusters)SQL Plus
Copyright © 2018. All Rights Reserved
Oracle Database Interview Question:
How To Use SQL Statements in PL/SQL?
Submitted by: AdministratorSQL DML (Data Manipulation Language) statements can be included in PL/SQL code blocks directly without any changes. See the script below for examples:
SQL> CREATE TABLE tip (id NUMBER(5) PRIMARY KEY,
2 subject VARCHAR(80) NOT NULL,
3 description VARCHAR(256) NOT NULL);
Table created.
SQL> BEGIN
2 INSERT INTO tip VALUES(1, 'PL/SQL',
3 'Good for beginners.');
4 UPDATE tip SET description = 'Good for beginners.';
5 END;
6 /
PL/SQL procedure successfully completed.
SQL> COL subject FORMAT A12;
SQL> COL description FORMAT A24;
SQL> SELECT * FROM tip;
<pre> ID SUBJECT DESCRIPTION
---------- ------------ -------------------
1 PL/SQL Good for beginners.</pre>
SQL> DROP TABLE tip;
Table dropped.
This script example actually has 3 parts:
► Part 1 - A single DDL (Data Definition Language) statement, CREATE TABLE, outside the PL/SQL code block.
► Part 2 - A PL/SQL code block defined and executed to insert and updated a record.
► Part 3 - A couple of SQL statements outside the PL/SQL code block to view the record and drop the table.
Submitted by: Administrator
SQL> CREATE TABLE tip (id NUMBER(5) PRIMARY KEY,
2 subject VARCHAR(80) NOT NULL,
3 description VARCHAR(256) NOT NULL);
Table created.
SQL> BEGIN
2 INSERT INTO tip VALUES(1, 'PL/SQL',
3 'Good for beginners.');
4 UPDATE tip SET description = 'Good for beginners.';
5 END;
6 /
PL/SQL procedure successfully completed.
SQL> COL subject FORMAT A12;
SQL> COL description FORMAT A24;
SQL> SELECT * FROM tip;
<pre> ID SUBJECT DESCRIPTION
---------- ------------ -------------------
1 PL/SQL Good for beginners.</pre>
SQL> DROP TABLE tip;
Table dropped.
This script example actually has 3 parts:
► Part 1 - A single DDL (Data Definition Language) statement, CREATE TABLE, outside the PL/SQL code block.
► Part 2 - A PL/SQL code block defined and executed to insert and updated a record.
► Part 3 - A couple of SQL statements outside the PL/SQL code block to view the record and drop the table.
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.