SlideShare a Scribd company logo
Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
8
Producing Readable Output
with SQL*Plus
8-2 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Objectives
After completing this lesson, you should
be able to do the following:
• Produce queries that require an input
variable
• Customize the SQL*Plus environment
• Produce more readable output
• Create and execute script files
• Save customizations
8-3 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Interactive Reports
I want to input query
values at runtime.
...sal = ? …
… deptno = ? …
.. ename = ? ...
User
8-4 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Substitution Variables
• Use SQL*Plus substitution variables to
temporarily store values.
– Single ampersand (&)
– Double ampersand (&&)
– DEFINE and ACCEPT commands
• Pass variable values between SQL
statements.
• Dynamically alter headers and footers.
8-5 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Using the & Substitution Variable
Use a variable prefixed with an
ampersand (&) to prompt the user for a
value.
SQL> SELECT empno, ename, sal, deptno
2 FROM emp
3 WHERE empno = &employee_num;
Enter value for employee_num: 7369
EMPNO ENAME SAL DEPTNO
--------- ---------- --------- ---------
7369 SMITH 800 20
8-6 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Using the SET VERIFY Command
Toggling the display of the text of a
command before and after SQL*Plus
replaces substitution variables with values.
SQL> SET VERIFY ON
SQL> SELECT empno, ename, sal, deptno
2 FROM emp
3 WHERE empno = &employee_num;
Enter value for employee_num: 7369
old 3: WHERE empno = &employee_num
new 3: WHERE empno = 7369
...
8-7 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Character and Date Values
with Substitution Variables
Use single quotation marks for date and
character values.
SQL> SELECT ename, deptno, sal*12
2 FROM emp
3 WHERE job='&job_title';
Enter value for job_title: ANALYST
ENAME DEPTNO SAL*12
---------- --------- ---------
SCOTT 20 36000
FORD 20 36000
8-8 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Specifying Column Names,
Expressions, and Text at Runtime
Use substitution variables to supplement
the following:
• WHERE condition
• ORDER BY clause
• Column expression
• Table name
• Entire SELECT statement
8-9 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Specifying Column Names,
Expressions, and Text at Runtime
SQL> SELECT empno, ename, job, &column_name
2 FROM emp
3 WHERE &condition
4 ORDER BY &order_column;
Enter value for column_name: sal
Enter value for condition: sal>=3000
Enter value for order_column: ename
EMPNO ENAME JOB SAL
--------- ---------- --------- ---------
7902 FORD ANALYST 3000
7839 KING PRESIDENT 5000
7788 SCOTT ANALYST 3000
8-10 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Using the && Substitution Variable
Use the double-ampersand (&&) if you
want to reuse the variable value without
prompting the user each time.
SQL> SELECT empno, ename, job, &&column_name
2 FROM emp
3 ORDER BY &column_name;
Enter value for column_name: deptno
EMPNO ENAME JOB DEPTNO
--------- ---------- --------- ---------
7839 KING PRESIDENT 10
7782 CLARK MANAGER 10
7934 MILLER CLERK 10
...
14 rows selected.
8-11 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Defining User Variables
• You can predefine variables using one
of two SQL*Plus commands:
– DEFINE: Create a CHAR datatype
user variable
– ACCEPT: Read user input and store it
in a variable
• If you need to predefine a variable that
includes spaces, you must enclose the
value within single quotation marks
when using the DEFINE command.
8-12 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
The ACCEPT Command
• Creates a customized prompt when
accepting user input
• Explicitly defines a NUMBER or DATE
datatype variable
• Hides user input for security reasons
ACCEPT variable [datatype] [FORMAT format]
[PROMPT text] [HIDE]
8-13 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Using the ACCEPT Command
ACCEPT dept PROMPT 'Provide the department name: '
SELECT *
FROM dept
WHERE dname = UPPER('&dept')
/
Provide the department name: Sales
DEPTNO DNAME LOC
--------- -------------- -------------
30 SALES CHICAGO
8-14 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
DEFINE and UNDEFINE Commands
• A variable remains defined until you either:
– Use the UNDEFINE command to clear it
– Exit SQL*Plus
• You can verify your changes with the
DEFINE command.
• To define variables for every session,
modify your login.sql file so that the
variables are created at startup.
8-15 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Using the DEFINE Command
• Create a variable to hold the department
name.
DEFINE DEPTNAME = "sales" (CHAR)
• Use the variable as you would any other
variable.
SQL> DEFINE deptname = sales
SQL> DEFINE deptname
SQL> SELECT *
2 FROM dept
3 WHERE dname = UPPER('&deptname');
8-16 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Customizing the SQL*Plus
Environment
• Use SET commands to control current
session.
• Verify what you have set by using the
SHOW command.
SQL> SET ECHO ON
SQL> SHOW ECHO
echo ON
SET system_variable value
8-17 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
SET Command Variables
• ARRAYSIZE {20 | n}
• COLSEP {_ | text}
• FEEDBACK {6 | n |OFF | ON}
• HEADING {OFF | ON}
• LINESIZE {80 | n}
• LONG {80 | n}
• PAGESIZE {24 | n}
• PAUSE {OFF | ON | text}
• TERMOUT {OFF | ON}
8-18 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Saving Customizations
in the login.sql File
• The login.sql file contains standard
SET and other SQL*Plus commands
that are implemented at login.
• You can modify login.sql to contain
additional SET commands.
8-19 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
SQL*Plus Format Commands
• COLUMN [column option]
• TTITLE [text | OFF | ON]
• BTITLE [text | OFF | ON]
• BREAK [ON report_element]
8-20 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
The COLUMN Command
Controls display of a column
• CLE[AR]: Clears any column formats
• FOR[MAT] format: Changes the display
of the column using a format model
• HEA[DING] text: Sets the column
heading
• JUS[TIFY] {align}: Aligns the column
heading to be left, center, or right
COL[UMN] [{column|alias} [option]]
8-21 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Using the COLUMN Command
• Create column headings.
• Display the current setting for the ENAME
column.
• Clear settings for the ENAME column.
COLUMN ename HEADING 'Employee|Name' FORMAT A15
COLUMN sal JUSTIFY LEFT FORMAT $99,990.00
COLUMN mgr FORMAT 999999999 NULL 'No manager'
COLUMN ename
COLUMN ename CLEAR
8-22 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
COLUMN Format Models
Result
N/A
1234
01234
$1234
L1234
1234.00
1,234
Example
N/A
999999
099999
$9999
L9999
9999.99
9,999
Element
An
9
0
$
L
.
,
Description
Sets a display width of n
Single zero-suppression
digit
Enforces leading zero
Floating dollar sign
Local currency
Position of decimal point
Thousand separator
8-23 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Using the BREAK Command
Suppresses duplicates and sections rows
• To suppress duplicates
SQL> BREAK ON ename ON job
SQL> BREAK ON ename SKIP 4 ON job SKIP 2
• To section out rows at break values
8-24 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Using the TTITLE and BTITLE
Commands
• Display headers and footers.
TTI[TLE] [text|OFF|ON]
SQL> TTITLE 'Salary|Report'
• Set the report header.
• Set the report footer.
SQL> BTITLE 'Confidential'
8-25 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Creating a Script File
to Run a Report
1. Create the SQL SELECT statement.
2. Save the SELECT statement to a script
file.
3. Load the script file into an editor.
4. Add formatting commands before the
SELECT statement.
5. Verify that the termination character
follows the SELECT statement.
8-26 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Creating a Script File
to Run a Report
6. Clear formatting commands after the
SELECT statement.
7. Save the script file.
8. Enter “START filename” to run the
script.
8-27 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Sample Report
Fri Oct 24 page 1
Employee
Report
Job
Category Employee Salary
----------------------- ----------------------- -----------------
CLERK ADAMS $1,100.00
JAMES $950.00
MILLER $1,300.00
SMITH $800.00
MANAGER BLAKE $2,850.00
CLARK $2,450.00
JONES $2,975.00
SALESMAN ALLEN $1,600.00
MARTIN $1,250.00
TURNER $1,500.00
WARD $1,250.00
Confidential
8-28 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Summary
• Use SQL*Plus substitution variables to
temporarily store values.
• Use SET commands to control current
SQL*Plus environment.
• Use the COLUMN command to control
the display of a column.
• Use the BREAK command to suppress
duplicates and section rows.
• Use TTITLE and BTITLE to display
headers and footers.
8-29 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved.
Practice Overview
• Creating a query to display values using
substitution variables
• Starting a command file containing
variables
• Using the ACCEPT command

More Related Content

What's hot

Les07[1]Multiple-Column Subqueries
Les07[1]Multiple-Column SubqueriesLes07[1]Multiple-Column Subqueries
Les07[1]Multiple-Column Subqueries
siavosh kaviani
 
Les09[1]Manipulating Data
Les09[1]Manipulating DataLes09[1]Manipulating Data
Les09[1]Manipulating Data
siavosh kaviani
 
Les10[1]Creating and Managing Tables
Les10[1]Creating and Managing TablesLes10[1]Creating and Managing Tables
Les10[1]Creating and Managing Tables
siavosh kaviani
 
Les18[1]Interacting with the Oracle Server
Les18[1]Interacting with  the Oracle ServerLes18[1]Interacting with  the Oracle Server
Les18[1]Interacting with the Oracle Server
siavosh kaviani
 
Les05[1]Aggregating Data Using Group Functions
Les05[1]Aggregating Data  Using Group FunctionsLes05[1]Aggregating Data  Using Group Functions
Les05[1]Aggregating Data Using Group Functions
siavosh kaviani
 
Les20[1]Working with Composite Datatypes
Les20[1]Working with Composite DatatypesLes20[1]Working with Composite Datatypes
Les20[1]Working with Composite Datatypes
siavosh kaviani
 
Les06[1]Subqueries
Les06[1]SubqueriesLes06[1]Subqueries
Les06[1]Subqueries
siavosh kaviani
 
Les21[1]Writing Explicit Cursors
Les21[1]Writing Explicit CursorsLes21[1]Writing Explicit Cursors
Les21[1]Writing Explicit Cursors
siavosh kaviani
 
Les19[1]Writing Control Structures
Les19[1]Writing Control StructuresLes19[1]Writing Control Structures
Les19[1]Writing Control Structures
siavosh kaviani
 
Les23[1]Handling Exceptions
Les23[1]Handling ExceptionsLes23[1]Handling Exceptions
Les23[1]Handling Exceptions
siavosh kaviani
 
Producing Readable Output with iSQL*Plus - Oracle Data Base
Producing Readable Output with iSQL*Plus - Oracle Data BaseProducing Readable Output with iSQL*Plus - Oracle Data Base
Producing Readable Output with iSQL*Plus - Oracle Data Base
Salman Memon
 
Displaying Data from Multiple Tables - Oracle Data Base
Displaying Data from Multiple Tables - Oracle Data BaseDisplaying Data from Multiple Tables - Oracle Data Base
Displaying Data from Multiple Tables - Oracle Data Base
Salman Memon
 
Writing Basic SQL SELECT Statements
Writing Basic SQL SELECT StatementsWriting Basic SQL SELECT Statements
Writing Basic SQL SELECT Statements
Salman Memon
 
Aggregating Data Using Group Functions
Aggregating Data Using Group FunctionsAggregating Data Using Group Functions
Aggregating Data Using Group Functions
Salman Memon
 
Creating Views - oracle database
Creating Views - oracle databaseCreating Views - oracle database
Creating Views - oracle database
Salman Memon
 
Sequences and indexes
Sequences and indexesSequences and indexes
Sequences and indexes
Balqees Al.Mubarak
 
Creating and Managing Tables -Oracle Data base
Creating and Managing Tables -Oracle Data base Creating and Managing Tables -Oracle Data base
Creating and Managing Tables -Oracle Data base
Salman Memon
 
Manipulating Data Oracle Data base
Manipulating Data Oracle Data baseManipulating Data Oracle Data base
Manipulating Data Oracle Data base
Salman Memon
 
Les03 (Using Single Row Functions To Customize Output)
Les03 (Using Single Row Functions To Customize Output)Les03 (Using Single Row Functions To Customize Output)
Les03 (Using Single Row Functions To Customize Output)
Achmad Solichin
 

What's hot (20)

Les07[1]Multiple-Column Subqueries
Les07[1]Multiple-Column SubqueriesLes07[1]Multiple-Column Subqueries
Les07[1]Multiple-Column Subqueries
 
Les09[1]Manipulating Data
Les09[1]Manipulating DataLes09[1]Manipulating Data
Les09[1]Manipulating Data
 
Les10[1]Creating and Managing Tables
Les10[1]Creating and Managing TablesLes10[1]Creating and Managing Tables
Les10[1]Creating and Managing Tables
 
Les18[1]Interacting with the Oracle Server
Les18[1]Interacting with  the Oracle ServerLes18[1]Interacting with  the Oracle Server
Les18[1]Interacting with the Oracle Server
 
Les05[1]Aggregating Data Using Group Functions
Les05[1]Aggregating Data  Using Group FunctionsLes05[1]Aggregating Data  Using Group Functions
Les05[1]Aggregating Data Using Group Functions
 
Les20[1]Working with Composite Datatypes
Les20[1]Working with Composite DatatypesLes20[1]Working with Composite Datatypes
Les20[1]Working with Composite Datatypes
 
Les06[1]Subqueries
Les06[1]SubqueriesLes06[1]Subqueries
Les06[1]Subqueries
 
Les21[1]Writing Explicit Cursors
Les21[1]Writing Explicit CursorsLes21[1]Writing Explicit Cursors
Les21[1]Writing Explicit Cursors
 
Les19[1]Writing Control Structures
Les19[1]Writing Control StructuresLes19[1]Writing Control Structures
Les19[1]Writing Control Structures
 
Les23[1]Handling Exceptions
Les23[1]Handling ExceptionsLes23[1]Handling Exceptions
Les23[1]Handling Exceptions
 
Producing Readable Output with iSQL*Plus - Oracle Data Base
Producing Readable Output with iSQL*Plus - Oracle Data BaseProducing Readable Output with iSQL*Plus - Oracle Data Base
Producing Readable Output with iSQL*Plus - Oracle Data Base
 
Displaying Data from Multiple Tables - Oracle Data Base
Displaying Data from Multiple Tables - Oracle Data BaseDisplaying Data from Multiple Tables - Oracle Data Base
Displaying Data from Multiple Tables - Oracle Data Base
 
Writing Basic SQL SELECT Statements
Writing Basic SQL SELECT StatementsWriting Basic SQL SELECT Statements
Writing Basic SQL SELECT Statements
 
Aggregating Data Using Group Functions
Aggregating Data Using Group FunctionsAggregating Data Using Group Functions
Aggregating Data Using Group Functions
 
plsql Les09
 plsql Les09 plsql Les09
plsql Les09
 
Creating Views - oracle database
Creating Views - oracle databaseCreating Views - oracle database
Creating Views - oracle database
 
Sequences and indexes
Sequences and indexesSequences and indexes
Sequences and indexes
 
Creating and Managing Tables -Oracle Data base
Creating and Managing Tables -Oracle Data base Creating and Managing Tables -Oracle Data base
Creating and Managing Tables -Oracle Data base
 
Manipulating Data Oracle Data base
Manipulating Data Oracle Data baseManipulating Data Oracle Data base
Manipulating Data Oracle Data base
 
Les03 (Using Single Row Functions To Customize Output)
Les03 (Using Single Row Functions To Customize Output)Les03 (Using Single Row Functions To Customize Output)
Les03 (Using Single Row Functions To Customize Output)
 

Similar to Les08[1] Producing Readable Output with SQL*Plus

Les01.ppt
Les01.pptLes01.ppt
Les01.ppt
sanasaeed84
 
Les01.pptx
Les01.pptxLes01.pptx
Les01.pptx
NishaTariq1
 
Les08-Oracle
Les08-OracleLes08-Oracle
Les08-Oraclesuman1248
 
Erik_van_Roon.pdf
Erik_van_Roon.pdfErik_van_Roon.pdf
Erik_van_Roon.pdf
DetchDuvanGaelaCamar
 
SQL, consultas rapidas y sencillas, oracle
SQL, consultas rapidas y sencillas, oracleSQL, consultas rapidas y sencillas, oracle
SQL, consultas rapidas y sencillas, oracle
marycielocartagena73
 
Less04_Database_Instance.ppt
Less04_Database_Instance.pptLess04_Database_Instance.ppt
Less04_Database_Instance.ppt
MuhammadUmair833474
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQL
rehaniltifat
 
Less08_Schema Advanced Databases and Management.pptx
Less08_Schema Advanced Databases and Management.pptxLess08_Schema Advanced Databases and Management.pptx
Less08_Schema Advanced Databases and Management.pptx
MurtazaMughal13
 
05 Creating Stored Procedures
05 Creating Stored Procedures05 Creating Stored Procedures
05 Creating Stored Procedures
rehaniltifat
 
Cursores.ppt
Cursores.pptCursores.ppt
Cursores.ppt
Alan737817
 
Database Management Systems SQL And DDL language
Database Management Systems SQL And DDL languageDatabase Management Systems SQL And DDL language
Database Management Systems SQL And DDL language
HSibghatUllah
 
Les09.ppt
Les09.pptLes09.ppt
e computer notes - Producing readable output with i sql plus
e computer notes - Producing readable output with i sql pluse computer notes - Producing readable output with i sql plus
e computer notes - Producing readable output with i sql plusecomputernotes
 
Intro.pptx
Intro.pptxIntro.pptx
Intro.pptx
NishaTariq1
 
Les03 Single Row Functions in Oracle and SQL.ppt
Les03 Single Row Functions in Oracle and SQL.pptLes03 Single Row Functions in Oracle and SQL.ppt
Les03 Single Row Functions in Oracle and SQL.ppt
DrZeeshanBhatti
 
Les01 Writing BAsic SQL SELECT Statement.ppt
Les01 Writing BAsic SQL SELECT Statement.pptLes01 Writing BAsic SQL SELECT Statement.ppt
Les01 Writing BAsic SQL SELECT Statement.ppt
DrZeeshanBhatti
 

Similar to Les08[1] Producing Readable Output with SQL*Plus (20)

Les01.ppt
Les01.pptLes01.ppt
Les01.ppt
 
Les01.pptx
Les01.pptxLes01.pptx
Les01.pptx
 
Les08-Oracle
Les08-OracleLes08-Oracle
Les08-Oracle
 
Erik_van_Roon.pdf
Erik_van_Roon.pdfErik_van_Roon.pdf
Erik_van_Roon.pdf
 
SQL, consultas rapidas y sencillas, oracle
SQL, consultas rapidas y sencillas, oracleSQL, consultas rapidas y sencillas, oracle
SQL, consultas rapidas y sencillas, oracle
 
Les01
Les01Les01
Les01
 
Les07
Les07Les07
Les07
 
Less04_Database_Instance.ppt
Less04_Database_Instance.pptLess04_Database_Instance.ppt
Less04_Database_Instance.ppt
 
Les09.ppt
Les09.pptLes09.ppt
Les09.ppt
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQL
 
Less08_Schema Advanced Databases and Management.pptx
Less08_Schema Advanced Databases and Management.pptxLess08_Schema Advanced Databases and Management.pptx
Less08_Schema Advanced Databases and Management.pptx
 
05 Creating Stored Procedures
05 Creating Stored Procedures05 Creating Stored Procedures
05 Creating Stored Procedures
 
Cursores.ppt
Cursores.pptCursores.ppt
Cursores.ppt
 
Database Management Systems SQL And DDL language
Database Management Systems SQL And DDL languageDatabase Management Systems SQL And DDL language
Database Management Systems SQL And DDL language
 
Les09.ppt
Les09.pptLes09.ppt
Les09.ppt
 
e computer notes - Producing readable output with i sql plus
e computer notes - Producing readable output with i sql pluse computer notes - Producing readable output with i sql plus
e computer notes - Producing readable output with i sql plus
 
Intro.pptx
Intro.pptxIntro.pptx
Intro.pptx
 
Les03 Single Row Functions in Oracle and SQL.ppt
Les03 Single Row Functions in Oracle and SQL.pptLes03 Single Row Functions in Oracle and SQL.ppt
Les03 Single Row Functions in Oracle and SQL.ppt
 
Les10
Les10Les10
Les10
 
Les01 Writing BAsic SQL SELECT Statement.ppt
Les01 Writing BAsic SQL SELECT Statement.pptLes01 Writing BAsic SQL SELECT Statement.ppt
Les01 Writing BAsic SQL SELECT Statement.ppt
 

More from siavosh kaviani

sara-shortCV SARA GHIASI TABRIZI Computer Science PhD Application
sara-shortCV SARA GHIASI TABRIZI Computer Science PhD Applicationsara-shortCV SARA GHIASI TABRIZI Computer Science PhD Application
sara-shortCV SARA GHIASI TABRIZI Computer Science PhD Application
siavosh kaviani
 
Introduction-to-the-Lean-Canvas.pdf
Introduction-to-the-Lean-Canvas.pdfIntroduction-to-the-Lean-Canvas.pdf
Introduction-to-the-Lean-Canvas.pdf
siavosh kaviani
 
Attaque chimique contre les écolières en Iran version 2.pptx
Attaque chimique contre les écolières en Iran version 2.pptxAttaque chimique contre les écolières en Iran version 2.pptx
Attaque chimique contre les écolières en Iran version 2.pptx
siavosh kaviani
 
Short CV BA.pdf
Short CV BA.pdfShort CV BA.pdf
Short CV BA.pdf
siavosh kaviani
 
Faegh Omidi Resume.pdf
Faegh Omidi Resume.pdfFaegh Omidi Resume.pdf
Faegh Omidi Resume.pdf
siavosh kaviani
 
Short CV CTO version 2.pdf
Short CV CTO version 2.pdfShort CV CTO version 2.pdf
Short CV CTO version 2.pdf
siavosh kaviani
 
Short CV Marketing version 2.pdf
Short CV Marketing version 2.pdfShort CV Marketing version 2.pdf
Short CV Marketing version 2.pdf
siavosh kaviani
 
Short CV prof version 2.pdf
Short CV prof version 2.pdfShort CV prof version 2.pdf
Short CV prof version 2.pdf
siavosh kaviani
 
Siavosh Kaviani cv francais 2022 version 2.pdf
Siavosh Kaviani cv francais 2022 version 2.pdfSiavosh Kaviani cv francais 2022 version 2.pdf
Siavosh Kaviani cv francais 2022 version 2.pdf
siavosh kaviani
 
SiavoshKaviani-CV[2021] francais.pdf
SiavoshKaviani-CV[2021] francais.pdfSiavoshKaviani-CV[2021] francais.pdf
SiavoshKaviani-CV[2021] francais.pdf
siavosh kaviani
 
apex security demo.ppsx
apex security demo.ppsxapex security demo.ppsx
apex security demo.ppsx
siavosh kaviani
 
Les14[1]Controlling User Access
Les14[1]Controlling User AccessLes14[1]Controlling User Access
Les14[1]Controlling User Access
siavosh kaviani
 
Les15[1]SQL Workshop
Les15[1]SQL WorkshopLes15[1]SQL Workshop
Les15[1]SQL Workshop
siavosh kaviani
 
Les11[1]Including Constraints
Les11[1]Including ConstraintsLes11[1]Including Constraints
Les11[1]Including Constraints
siavosh kaviani
 

More from siavosh kaviani (14)

sara-shortCV SARA GHIASI TABRIZI Computer Science PhD Application
sara-shortCV SARA GHIASI TABRIZI Computer Science PhD Applicationsara-shortCV SARA GHIASI TABRIZI Computer Science PhD Application
sara-shortCV SARA GHIASI TABRIZI Computer Science PhD Application
 
Introduction-to-the-Lean-Canvas.pdf
Introduction-to-the-Lean-Canvas.pdfIntroduction-to-the-Lean-Canvas.pdf
Introduction-to-the-Lean-Canvas.pdf
 
Attaque chimique contre les écolières en Iran version 2.pptx
Attaque chimique contre les écolières en Iran version 2.pptxAttaque chimique contre les écolières en Iran version 2.pptx
Attaque chimique contre les écolières en Iran version 2.pptx
 
Short CV BA.pdf
Short CV BA.pdfShort CV BA.pdf
Short CV BA.pdf
 
Faegh Omidi Resume.pdf
Faegh Omidi Resume.pdfFaegh Omidi Resume.pdf
Faegh Omidi Resume.pdf
 
Short CV CTO version 2.pdf
Short CV CTO version 2.pdfShort CV CTO version 2.pdf
Short CV CTO version 2.pdf
 
Short CV Marketing version 2.pdf
Short CV Marketing version 2.pdfShort CV Marketing version 2.pdf
Short CV Marketing version 2.pdf
 
Short CV prof version 2.pdf
Short CV prof version 2.pdfShort CV prof version 2.pdf
Short CV prof version 2.pdf
 
Siavosh Kaviani cv francais 2022 version 2.pdf
Siavosh Kaviani cv francais 2022 version 2.pdfSiavosh Kaviani cv francais 2022 version 2.pdf
Siavosh Kaviani cv francais 2022 version 2.pdf
 
SiavoshKaviani-CV[2021] francais.pdf
SiavoshKaviani-CV[2021] francais.pdfSiavoshKaviani-CV[2021] francais.pdf
SiavoshKaviani-CV[2021] francais.pdf
 
apex security demo.ppsx
apex security demo.ppsxapex security demo.ppsx
apex security demo.ppsx
 
Les14[1]Controlling User Access
Les14[1]Controlling User AccessLes14[1]Controlling User Access
Les14[1]Controlling User Access
 
Les15[1]SQL Workshop
Les15[1]SQL WorkshopLes15[1]SQL Workshop
Les15[1]SQL Workshop
 
Les11[1]Including Constraints
Les11[1]Including ConstraintsLes11[1]Including Constraints
Les11[1]Including Constraints
 

Recently uploaded

The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 

Recently uploaded (20)

The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 

Les08[1] Producing Readable Output with SQL*Plus

  • 1. Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. 8 Producing Readable Output with SQL*Plus
  • 2. 8-2 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Objectives After completing this lesson, you should be able to do the following: • Produce queries that require an input variable • Customize the SQL*Plus environment • Produce more readable output • Create and execute script files • Save customizations
  • 3. 8-3 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Interactive Reports I want to input query values at runtime. ...sal = ? … … deptno = ? … .. ename = ? ... User
  • 4. 8-4 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Substitution Variables • Use SQL*Plus substitution variables to temporarily store values. – Single ampersand (&) – Double ampersand (&&) – DEFINE and ACCEPT commands • Pass variable values between SQL statements. • Dynamically alter headers and footers.
  • 5. 8-5 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Using the & Substitution Variable Use a variable prefixed with an ampersand (&) to prompt the user for a value. SQL> SELECT empno, ename, sal, deptno 2 FROM emp 3 WHERE empno = &employee_num; Enter value for employee_num: 7369 EMPNO ENAME SAL DEPTNO --------- ---------- --------- --------- 7369 SMITH 800 20
  • 6. 8-6 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Using the SET VERIFY Command Toggling the display of the text of a command before and after SQL*Plus replaces substitution variables with values. SQL> SET VERIFY ON SQL> SELECT empno, ename, sal, deptno 2 FROM emp 3 WHERE empno = &employee_num; Enter value for employee_num: 7369 old 3: WHERE empno = &employee_num new 3: WHERE empno = 7369 ...
  • 7. 8-7 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Character and Date Values with Substitution Variables Use single quotation marks for date and character values. SQL> SELECT ename, deptno, sal*12 2 FROM emp 3 WHERE job='&job_title'; Enter value for job_title: ANALYST ENAME DEPTNO SAL*12 ---------- --------- --------- SCOTT 20 36000 FORD 20 36000
  • 8. 8-8 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Specifying Column Names, Expressions, and Text at Runtime Use substitution variables to supplement the following: • WHERE condition • ORDER BY clause • Column expression • Table name • Entire SELECT statement
  • 9. 8-9 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Specifying Column Names, Expressions, and Text at Runtime SQL> SELECT empno, ename, job, &column_name 2 FROM emp 3 WHERE &condition 4 ORDER BY &order_column; Enter value for column_name: sal Enter value for condition: sal>=3000 Enter value for order_column: ename EMPNO ENAME JOB SAL --------- ---------- --------- --------- 7902 FORD ANALYST 3000 7839 KING PRESIDENT 5000 7788 SCOTT ANALYST 3000
  • 10. 8-10 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Using the && Substitution Variable Use the double-ampersand (&&) if you want to reuse the variable value without prompting the user each time. SQL> SELECT empno, ename, job, &&column_name 2 FROM emp 3 ORDER BY &column_name; Enter value for column_name: deptno EMPNO ENAME JOB DEPTNO --------- ---------- --------- --------- 7839 KING PRESIDENT 10 7782 CLARK MANAGER 10 7934 MILLER CLERK 10 ... 14 rows selected.
  • 11. 8-11 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Defining User Variables • You can predefine variables using one of two SQL*Plus commands: – DEFINE: Create a CHAR datatype user variable – ACCEPT: Read user input and store it in a variable • If you need to predefine a variable that includes spaces, you must enclose the value within single quotation marks when using the DEFINE command.
  • 12. 8-12 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. The ACCEPT Command • Creates a customized prompt when accepting user input • Explicitly defines a NUMBER or DATE datatype variable • Hides user input for security reasons ACCEPT variable [datatype] [FORMAT format] [PROMPT text] [HIDE]
  • 13. 8-13 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Using the ACCEPT Command ACCEPT dept PROMPT 'Provide the department name: ' SELECT * FROM dept WHERE dname = UPPER('&dept') / Provide the department name: Sales DEPTNO DNAME LOC --------- -------------- ------------- 30 SALES CHICAGO
  • 14. 8-14 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. DEFINE and UNDEFINE Commands • A variable remains defined until you either: – Use the UNDEFINE command to clear it – Exit SQL*Plus • You can verify your changes with the DEFINE command. • To define variables for every session, modify your login.sql file so that the variables are created at startup.
  • 15. 8-15 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Using the DEFINE Command • Create a variable to hold the department name. DEFINE DEPTNAME = "sales" (CHAR) • Use the variable as you would any other variable. SQL> DEFINE deptname = sales SQL> DEFINE deptname SQL> SELECT * 2 FROM dept 3 WHERE dname = UPPER('&deptname');
  • 16. 8-16 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Customizing the SQL*Plus Environment • Use SET commands to control current session. • Verify what you have set by using the SHOW command. SQL> SET ECHO ON SQL> SHOW ECHO echo ON SET system_variable value
  • 17. 8-17 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. SET Command Variables • ARRAYSIZE {20 | n} • COLSEP {_ | text} • FEEDBACK {6 | n |OFF | ON} • HEADING {OFF | ON} • LINESIZE {80 | n} • LONG {80 | n} • PAGESIZE {24 | n} • PAUSE {OFF | ON | text} • TERMOUT {OFF | ON}
  • 18. 8-18 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Saving Customizations in the login.sql File • The login.sql file contains standard SET and other SQL*Plus commands that are implemented at login. • You can modify login.sql to contain additional SET commands.
  • 19. 8-19 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. SQL*Plus Format Commands • COLUMN [column option] • TTITLE [text | OFF | ON] • BTITLE [text | OFF | ON] • BREAK [ON report_element]
  • 20. 8-20 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. The COLUMN Command Controls display of a column • CLE[AR]: Clears any column formats • FOR[MAT] format: Changes the display of the column using a format model • HEA[DING] text: Sets the column heading • JUS[TIFY] {align}: Aligns the column heading to be left, center, or right COL[UMN] [{column|alias} [option]]
  • 21. 8-21 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Using the COLUMN Command • Create column headings. • Display the current setting for the ENAME column. • Clear settings for the ENAME column. COLUMN ename HEADING 'Employee|Name' FORMAT A15 COLUMN sal JUSTIFY LEFT FORMAT $99,990.00 COLUMN mgr FORMAT 999999999 NULL 'No manager' COLUMN ename COLUMN ename CLEAR
  • 22. 8-22 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. COLUMN Format Models Result N/A 1234 01234 $1234 L1234 1234.00 1,234 Example N/A 999999 099999 $9999 L9999 9999.99 9,999 Element An 9 0 $ L . , Description Sets a display width of n Single zero-suppression digit Enforces leading zero Floating dollar sign Local currency Position of decimal point Thousand separator
  • 23. 8-23 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Using the BREAK Command Suppresses duplicates and sections rows • To suppress duplicates SQL> BREAK ON ename ON job SQL> BREAK ON ename SKIP 4 ON job SKIP 2 • To section out rows at break values
  • 24. 8-24 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Using the TTITLE and BTITLE Commands • Display headers and footers. TTI[TLE] [text|OFF|ON] SQL> TTITLE 'Salary|Report' • Set the report header. • Set the report footer. SQL> BTITLE 'Confidential'
  • 25. 8-25 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Creating a Script File to Run a Report 1. Create the SQL SELECT statement. 2. Save the SELECT statement to a script file. 3. Load the script file into an editor. 4. Add formatting commands before the SELECT statement. 5. Verify that the termination character follows the SELECT statement.
  • 26. 8-26 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Creating a Script File to Run a Report 6. Clear formatting commands after the SELECT statement. 7. Save the script file. 8. Enter “START filename” to run the script.
  • 27. 8-27 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Sample Report Fri Oct 24 page 1 Employee Report Job Category Employee Salary ----------------------- ----------------------- ----------------- CLERK ADAMS $1,100.00 JAMES $950.00 MILLER $1,300.00 SMITH $800.00 MANAGER BLAKE $2,850.00 CLARK $2,450.00 JONES $2,975.00 SALESMAN ALLEN $1,600.00 MARTIN $1,250.00 TURNER $1,500.00 WARD $1,250.00 Confidential
  • 28. 8-28 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Summary • Use SQL*Plus substitution variables to temporarily store values. • Use SET commands to control current SQL*Plus environment. • Use the COLUMN command to control the display of a column. • Use the BREAK command to suppress duplicates and section rows. • Use TTITLE and BTITLE to display headers and footers.
  • 29. 8-29 Copyright ‫س‬ Oracle Corporation, 1999. All rights reserved. Practice Overview • Creating a query to display values using substitution variables • Starting a command file containing variables • Using the ACCEPT command