Tec&Cult
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Tec&Cult

Technologie et Culture
 
AccueilAccueil  PortailPortail  GalerieGalerie  Dernières imagesDernières images  RechercherRechercher  S'enregistrerS'enregistrer  Connexion  
Sujets similaires
Rechercher
 
 

Résultats par :
 
Rechercher Recherche avancée
Derniers sujets
» Que faire à Paris le week-end du 15 août ?
PL/SQL Tutorial EmptyJeu 11 Aoû - 11:20 par Admin

» T-shirt Mec de Paname
PL/SQL Tutorial EmptyMer 3 Aoû - 17:04 par Admin

» dating web site uk dating free parent single
PL/SQL Tutorial EmptyMer 3 Aoû - 10:56 par Invité

» rsvp dating website seeking bisexual
PL/SQL Tutorial EmptyLun 1 Aoû - 2:08 par Invité

» dating french woman gay bottom seeking tops
PL/SQL Tutorial EmptyDim 31 Juil - 21:59 par Invité

» dating philippine woman man seeking wealthy woman
PL/SQL Tutorial EmptyVen 29 Juil - 12:51 par Invité

» dating lesbian n r cacee cobb dating lachey nick
PL/SQL Tutorial EmptyVen 29 Juil - 3:17 par Invité

» single dating chat room relationship dating advice
PL/SQL Tutorial EmptyJeu 28 Juil - 0:21 par Invité

» скачать порно тетя скачать порнофото семейное
PL/SQL Tutorial EmptyJeu 21 Juil - 14:34 par Invité

Navigation
 Portail
 Index
 Membres
 Profil
 FAQ
 Rechercher
Forum
Partenaires
Forum gratuit


Tchat Blablaland
-29%
Le deal à ne pas rater :
Pack Smartphone Google Pixel 8a 5G 128 Go + Ecouteurs Google Pixel
469 € 659 €
Voir le deal

Partagez | 
 

 PL/SQL Tutorial

Voir le sujet précédent Voir le sujet suivant Aller en bas 
AuteurMessage
Admin
Admin


Messages : 156
Date d'inscription : 20/05/2010

PL/SQL Tutorial _
MessageSujet: PL/SQL Tutorial   PL/SQL Tutorial EmptyVen 5 Nov - 12:54

http://toptech.geekaddict.net/
Need for PL/SQL — declarative vs. procedural — anonymous blocks — debugging — a first program — code compilation — code execution — procedures & functions — PL/SQL in SQL — SQL in PL/SQL — cursors & loops — operators & built-in functions reference tables.
Introduction

PL/SQL is a database-oriented programming language that extends Oracle SQL with procedural capabilities. We will review in this lab the fundamental features of the language and learn how to integrate it with SQL to help solve database problems.


Need for PL/SQL

SQL statements are defined in term of constraints we wish to fix on the result of a query. Such a language is commonly referred to as declarative. This contrasts with the so called procedural languages where a program specifies a list of operations to be performed sequentially to achieve the desired result. PL/SQL adds selective (i.e. if...then...else...) and iterative constructs (i.e. loops) to SQL.
PL/SQL is most useful to write triggers and stored procedures. Stored procedures are units of procedural code stored in a compiled form within the database.
PL/SQL Fundamentals

PL/SQL programs are organised in functions, procedures and packages (somewhat similar to Java packages). There is a limited support for object-oriented programming. PL/SQL is based on the Ada programming language, and as such it shares many elements of its syntax with Pascal.
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.

SQL> SET SERVEROUTPUT ON

SQL> BEGIN
2 dbms_output.put_line('Welcome to PL/SQL');
3 END;
4 /

SET SERVEROUTPUT ON is the SQL*Plus command1 to activate the console output. You only need to issue this command once in a SQL*Plus session.
the keywords BEGIN...END define a scope and are equivalent to the curly braces in Java {...}
a semi-column character (Wink marks the end of a statement
the put_line function (in the built-in package dbms_output) displays a string in the SQL*Plus console.
You are referred to Table 2 for a list of operators, and to Table 3 for some useful built-in functions.

Compiling your code.

PL/SQL code is compiled by submitting it to SQL*Plus. Remember that it is advisable to type your program in an external editor, as you have done with SQL (see Introduction to Oracle).
Debugging.

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:
SQL> SHOW ERRORS
to see your errors listed. If yo 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). For example, if Oracle reports ``error PLS-00103'', you should type:

oerr PLS 00103
at the UNIX command prompt (i.e. not in SQL*Plus).

Executing PL/SQL

If you have submitted the program above to Oracle, you have probably noticed that it is executed straight away. This is the case for anonymous blocks, but not for procedures and functions. The simplest way to run a function (e.g. sysdate) is to call it from within an SQL statement:
SQL> SELECT sysdate FROM DUAL
2 /

Next, we will rewrite the anonymous block above as a procedure. Note that we now use the user function to greet the user.

CREATE OR REPLACE PROCEDURE welcome
IS
user_name VARCHAR2(Cool := user;
BEGIN -- `BEGIN' ex
dbms_output.put_line('Welcome to PL/SQL, '
|| user_name || '!');
END;
/
Make sure you understand the changes made in the code:

A variable user_name of type VARCHAR2 is declared
user_name is initialised using the user2 built-in function
``:='' is the assignment operator (see. Table 2)
Once you have compiled the procedure, execute it using the EXEC command.


SQL> EXEC welcome
Both procedures and functions should remind you of Java methods. The similarities and differences between them are outlined in Table 1.



Table 1: Functions, procedures and Java methods compared.
Function Procedure Java Method
Parameters input, output input, output input
Returns value yes no optional
Can be called within SQL yes no
Revenir en haut Aller en bas
http://toptech.geekaddict.net
 

PL/SQL Tutorial

Voir le sujet précédent Voir le sujet suivant Revenir en haut 
Page 1 sur 1

Permission de ce forum:Vous ne pouvez pas répondre aux sujets dans ce forum
Tec&Cult :: Informatique :: Oracle :: Oracle PL SQL-
Sauter vers: