1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Using SQL *Plus to Create Report and Manage Pl/SQL code doc

50 371 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 50
Dung lượng 297,45 KB

Nội dung

Using SQL*Plus to Create Reports and Manage PL/SQL Code C Introduction to Oracle: SQL and PL/SQL Using Procedure BuilderCĆ2 Using SQL*Plus to Create Reports and Manage PL/SQL Code CĆ3 Objectives This lesson covers formatting query output to produce simple reports, controlling the SQL*Plus environment, and manipulating PL/SQL code using SQL*Plus. At the end of this lesson, you should be able to D Differentiate between SQL and SQL*Plus commands. D Identify SET commands used to control the SQL*Plus environment. D Customize reports using SQL*Plus formatting commands. D Create and modify anonymous blocks and program units with SQL*Plus and the online editor. D Execute SQL*Plus commands, anonymous blocks, program units, and SQL statements. D Compile procedures and functions. D Embed messages to assist with debugging code. Introduction to Oracle: SQL and PL/SQL Using Procedure BuilderCĆ4 The SQL*Plus Environment Using SQL*Plus to Create Reports and Manage PL/SQL Code CĆ5 Overview SQL*Plus is an environment in which you can D Execute SQL statements to retrieve, modify, add, and remove data from database tables. D Format, perform calculations on, store, and print query results in the form of reports. D Issue SQL statements to create, alter, and remove database tables. D Create anonymous blocks, subprograms, database triggers using procedural language extension, PL/SQL. SQL*Plus has a variety of commands you need to use to execute subprograms, pass values in and out of PL/SQL blocks, and debug your code. SQL*Plus commands may be divided into the following main categories. Category Purpose Environment Affects the general behavior of SQL statements for the session. Format Formats query results. File manipulation Saves, loads, and runs script files. Execution Sends SQL or PL/SQL commands from SQL buffer to Oracle7 Server. Edit Modifies SQL commands in the buffer. Interaction Allows users to create and pass variables to SQL statements, print variable values, and print messages to the screen. Miscellaneous Various commands to connect to the database, manipulate the SQL*Plus environment, and display column definitions. Introduction to Oracle: SQL and PL/SQL Using Procedure BuilderCĆ6 Entering Commands in SQL*Plus Using SQL*Plus to Create Reports and Manage PL/SQL Code CĆ7 Entering Commands in SQL*Plus Once you log in to SQL*Plus, you see the command prompt. Issue all your commands at this prompt. Three types of commands can be entered at this prompt. D SQL commands to manipulate data and structures in the database. D SQL*Plus command to format query results, set the environment, edit commands, and create variables. D PL/SQL blocks to work with information in the database in a procedural method. To execute commands, type them at the command prompt. SQL*Plus commands do not need to be terminated with a semicolon (;). SQL statements and PL/SQL blocks do need to be terminated with a semicolon to send the statement to the Oracle7 Server. Introduction to Oracle: SQL and PL/SQL Using Procedure BuilderCĆ8 Using SQL*Plus to Create Reports and Manage PL/SQL Code CĆ9 Comparison of SQL and SQL*Plus Commands This table compares SQL and SQL*Plus commands. They are distinctly different programs, but are used together to perform some tasks, such as to format data in a report and to control command files. SQL SQL*Plus Is a language for communicating with the Oracle Server to access data. Recognizes SQL commands, and sends them to the server. Is based on American National Standards Institute (ANSI) standard SQL. Is the Oracle proprietary interface for executing SQL commands. Manipulates data and table definitions in the database. Does not allow you to manipulate values in the database. Is entered into the SQL*Buffer on one or more lines. Is entered one line at a time; not stored in the SQL buffer. Does not have a continuation character. Has a dash “-” as a continuation character if the command is longer than one line. Cannot be abbreviated. Can be abbreviated. Uses a termination character to execute commands required. Does not require termination characters; commands are immediately executed. Uses functions to perform some formatting. Uses commands to format data. Introduction to Oracle: SQL and PL/SQL Using Procedure BuilderCĆ10 [...]... each iteration of the loop Using SQL* Plus to Create Reports and Manage PL /SQL Code CĆ23 SQL* Plus Commands CĆ24 Introduction to Oracle: SQL and PL /SQL Using Procedure Builder Entering Commands in SQL* Plus SQL* Plus contains an array of commands to format reports and initiate the users’ environment SQL* Plus Command Description ACCEPT Reads input from the user and stores the input into a variable VARIABLE... comment in SQL* Plus Using SQL* Plus to Create Reports and Manage PL /SQL Code CĆ21 Declaring and Creating PL /SQL Blocks CĆ22 Introduction to Oracle: SQL and PL /SQL Using Procedure Builder Declaring and Creating PL /SQL Blocks You can use two methods to process PL /SQL blocks in SQL* Plus D Define a block in the SQL buffer, then execute the contents of the buffer D Define a block as part of a SQL* Plus script... message from the PL /SQL engine indicating that an error occurred while performing some of the tasks in the block Handling of exceptions is covered in lesson 25 of this course Using SQL* Plus to Create Reports and Manage PL /SQL Code CĆ31 CĆ32 Introduction to Oracle: SQL and PL /SQL Using Procedure Builder Debugging in SQL* Plus continued One method for debugging your PL /SQL block using SQL* Plus is to embed global... footer BTITLE OFF Turns the footer off Using SQL* Plus to Create Reports and Manage PL /SQL Code CĆ17 CĆ18 Introduction to Oracle: SQL and PL /SQL Using Procedure Builder Creating a Report continued Creating the Script File to Run a Report You can either enter each of the SQL* Plus commands at the SQL prompt or put all the commands, including the SELECT statement, in a command (or script) file A typical script... an alias to your column, you must reference the alias name, not the column name Using SQL* Plus to Create Reports and Manage PL /SQL Code CĆ15 CĆ16 Introduction to Oracle: SQL and PL /SQL Using Procedure Builder Creating a Report continued TTITLE and BTITLE Commands Use the TTITLE command to format page headers and the BTITLE command for footers Footers appear at the end of the page according to the PAGESIZE... SQL* Plus environment Using SQL* Plus to Create Reports and Manage PL /SQL Code CĆ19 1 2 3 1 Header CĆ20 2 Column labels and format 3 Footer Introduction to Oracle: SQL and PL /SQL Using Procedure Builder Creating a Report continued Example Create a script file to create a report which displays the job title, last name, and salary for every employee who is not a vice president or a warehouse manager Add a centered,... variable that can be referenced in PL /SQL with a preceding colon (:) PRINT Displays the current value of bind variables EXECUTE Executes a single PL /SQL statement For more information, see SQL* Plus User’s Guide and Reference, Release 3.3 Using SQL* Plus to Create Reports and Manage PL /SQL Code CĆ25 CĆ26 Introduction to Oracle: SQL and PL /SQL Using Procedure Builder Passing Input and Output Values A substitution... CĆ28 Introduction to Oracle: SQL and PL /SQL Using Procedure Builder Passing Input and Output Values continued Output Values Output a value from the PL /SQL block into SQL* Plus by using a SQL* Plus global variable Follow the steps listed below 1 Outside the PL /SQL block, declare a SQL* Plus global variable with the SQL* Plus VARIABLE command 2 Within the PL /SQL block, embed the SQL* Plus global variable wherever... Oracle: SQL and PL /SQL Using Procedure Builder Creating a Report Script File You can create a script file (or command file) that includes both a SQL SELECT statement and SQL* Plus commands used to format and reset command values Script files are useful for saving both a SQL statement and any SQL* Plus settings specific to that statement Additionally, you can create a file to hold all your default SQL* Plus... the PL /SQL block, print the output value on the screen with the SQL* Plus PRINT command Syntax VARIABLE variable [NUMBER|CHAR|CHAR(n)|VARCHAR2(n)] PRINT variable where: variable n is the name of the bind variable is the maximum length for the datatype Using SQL* Plus to Create Reports and Manage PL /SQL Code CĆ29 CĆ30 Introduction to Oracle: SQL and PL /SQL Using Procedure Builder Debugging in SQL* Plus . Using SQL* Plus to Create Reports and Manage PL /SQL Code C Introduction to Oracle: SQL and PL /SQL Using Procedure BuilderCĆ2 Using SQL* Plus to Create Reports. Oracle7 Server. Introduction to Oracle: SQL and PL /SQL Using Procedure BuilderCĆ8 Using SQL* Plus to Create Reports and Manage PL /SQL Code CĆ9 Comparison of SQL and SQL* Plus Commands This

Ngày đăng: 17/01/2014, 09:20

TỪ KHÓA LIÊN QUAN

w