Tutorials
Oracle 9i
Tutorial 1: Introduction to Oracle 9i:SQL, PLSQL. and SQL *Plus
Introduction to SQLAll of these block types share most PL/SQL features so during this tutorial the features that apply to all block types will be grouped into single subjects.
As you can see there are several elements in the example that haven't been covered in the SQL tutorial, these elements are the PL/SQL extensions. They include:
| Variables and Constants | These objects are used to store and manipulate block level data. They can be CHAR, VARCHAR2, NUMBER, DATE or BOOLEAN data types. |
| SQL support | All SQL statements are supported within PL/SQL blocks including transaction control statements. |
| Composite Data types | Records allow groups of fields to be defined and manipulated in PL/SQL blocks. |
| Flow Control | If, Loop, GOTO and Labels provide conditional actions, tests, branching and iterative program control. |
| Built-in functions | Most SQL data functions are supported within PL/SQL blocks. |
| Cursor handling | Cursors (a memory area holding a result set) can be explicitly defined and manipulated allowing the processing of multiple rows. A group of PL/SQL system attributes provide the ability to test a cursor's internal state. |
| Exception handling | Blocks have the ability to trap and handle local error conditions (implicit exceptions). You may also self generate explicit exceptions that deal with logic and data errors. |
| Code storage | Blocks may be stored within an Oracle database as procedures, functions, packages (a group of blocks) and triggers. |
Rules of block Structure
Your first example in PL/SQL will be an anonymous block --that is a short program that is ran once, but that is neither named nor stored persistently in the database.
|
PL/SQL code is compiled by submitting it to SQL*Plus. Unless your program is an anonymous block, your errors will not be reported. Instead, SQL*Plus will display the message ``warning: procedure created with compilation errors''. You will then need to type:
|
to see your errors listed. If you do not understand the error message and you are using Oracle on UNIX, you may be able to get a more detailed description using the oerr utility, otherwise use Oracle's documentation (see References section).
|
Next, we will rewrite the anonymous block above as a procedure. Note that we now use the user function to greet the user.
|
Make sure you understand the changes made in the code: Once you have compiled the procedure, execute it using the EXEC command.
|
Generating Output on Screen
The built-in packages offer a number of ways to generate output from within your PL/SQL program. While updating a database table is, of course, a form of "output" from PL/SQL, this chapter shows you how to use two packages that explicitly generate output. UTL_FILE reads and writes information in server-side files, and DBMS_OUTPUT displays information to your screen.
Here is a very good chapter from O'Reilly which helps to understand the complete concept and usage of “Generating Output on Screen” Click here to Read
First Page: Tutorial 1: Introduction to Oracle 9i:SQL, PLSQL. and SQL *Plus
| its really fantastic to loacte the reqvired matter here. thanx |
| thanks so much |
| how will transfer the data from flat file to database by using pl/sql |
| thanks! sir |
| This tutorial is very help full for beginers |
| Good one for beginners to learn sql |
| thanks for your help. This tutorial is very ususfull for us beginers. |
|
where will i get the solutions for the practice questions in the book introduction to oracle9i:sql one more question is, what is the query to display the last name and the job title of a table who do not have a manager? |
| Thanks For this hard works Great. |
| I would like to look for the course around chennai on Oracle apps supply chain mgmt and financials. [Oracle certified institute] |