By Bill Pribyl
With Steven Feuerstein
Price: $49.99 USD
£28.50 GBP
Cover | Table of Contents | Colophon
EXCEPTION
END;
EXCEPTION
END;
printme,
balance_in_$, book2.
BEGIN
DBMS_OUTPUT.PUT_LINE('hello, world');
END;
OS> sqlplus
OS> for the
operating system command prompt. On MS Windows it might say
C:\>, and on Unix, $.)
variable_name VARCHAR2(n);
DECLARE
small_string VARCHAR2(4);
line_of_text VARCHAR2(2000);
biggest_string_allowed VARCHAR2(32767);
BEGIN
biggest_string_allowed := 'Tiny';
line_of_text := 'Tiny';
IF biggest_string_allowed = line_of_text
THEN
DBMS_OUTPUT.PUT_LINE ('They match!');
END IF;
END;|
Operator Category
|
Notation
|
Meaning
|
|---|---|---|
|
Assignment
|
:= |
Store the value
|
|
Arithmetic
|
+
-
/
*
**
|
Addition
Subtraction
Division
Multiplication
Exponentiation
|
|
Logical
|
AND
OR
NOT
|
IF condition1 THEN statements [ ELSIF condition2 THEN statements ] ... [ ELSIF conditionn THEN statements ] [ ELSE last_statements ] END IF;
IF book_count > 10000
THEN
ready := TRUE;
DBMS_OUTPUT.PUT_LINE ('We''re ready to open the library!');
END IF;
IF hourly_wage < 10 THEN hourly_wage := hourly_wage * 1.5; ELSE hourly_wage := hourly_wage * 1.1; END IF;
favorite_flavor VARCHAR2(20); Favorite_Flavor varchar2(20); fAvOrItE_flaVOR vArCHAr(20);
favorite_flavor VARCHAR2(20);
favorite_flavor VARCHAR2(20);
favorite_flavor
VARCHAR2
( 20 ) ;
=) operator (as opposed to the proper way, using
IS NULL) puts you on the road to doom. Let's look at a few
other close encounters you're likely to have with NULLs.
DECLARE empty VARCHAR2(2000); -- defaults to null the_enemy VARCHAR2(200); BEGIN the_enemy := 'blue' || empty || 'meanies'; END;
INSERT INTO books (isbn, title, author)
VALUES ('0-596-00180-0', 'Learning Oracle PL/SQL, 'Bill Pribyl with Steven Feuerstein');
Centralize SQL statements in reusable PL/SQL programs, rather than scattering them helter-skelter throughout various applications.
CREATE [ OR REPLACE ] FUNCTION procedure_name (parameter1 MODE DATATYPE DEFAULT expression, parameter2 MODE DATATYPE DEFAULT expression, ...) RETURN DATATYPE AS [ variable1 DATATYPE; variable2 DATATYPE; ... ] BEGIN executable_statement; RETURN expression; [ EXCEPTION WHEN exception_name THEN executable_statement; ] END; /
RETURN
datatype
RETURN
expression
reporteq
) procedure:
books table
already exists? Is that the same thing as adding a new copy of the
book?
|
Filename pattern
|
Contents
|
|---|---|
|
name
.pro
|
(Standalone) stored procedure
|
|
name
.fun
|
(Standalone) stored function
|
|
name
.sql
|
Anonymous block or script containing multiple blocks, SQL statements,
and/or SQL*Plus commands
|
|
name
.pks
|
Package specification
|
|
name
.pkb
|