Script for Creating and Using the Library Tutorial ObjectsREFERENCES books(book_id),transaction_date DATECONSTRAINT tran_date_not_null NOT NULL,transaction_type NUMBERCONSTRAINT tran_type_not_null NOT NULL);CREATE SEQUENCE patron_id_seqSTART WITH 100INCREMENT BY 1;-- The actual sequence for the transaction_id-- in the tutorial is created automatically,-- and probably has a name in the form MDRS_xxx$.CREATE SEQUENCE trans_id_seqSTART WITH 1INCREMENT BY 1;CREATE OR REPLACE TRIGGER ins_transactionsBEFORE INSERT ON TRANSACTIONSFOR EACH ROWBEGINSELECT trans_id_seq.nextval INTO:new.TRANSACTION_ID FROM dual;END;/CREATE VIEW patrons_trans_view ASSELECT p.patron_id, p.last_name, p.first_name,t.transaction_type, t.transaction_dateFROM patrons p, transactions tWHERE p.patron_id = t.patron_idORDER BY p.patron_id, t.transaction_type;-- Procedure: List all books that have a specified rating.CREATE OR REPLACE PROCEDURE list_a_rating(in_rating IN NUMBER) ASmatching_title VARCHAR2(50);TYPE my_cursor IS REF CURSOR;the_cursor my_cursor;BEGINOPEN the_cursor FOR 'SELECT title FROM books WHERErating = :in_rating' USING in_rating;DBMS_OUTPUT.PUT_LINE('All books with a rating of ' || in_rating || ':');LOOPFETCH the_cursor INTO matching_title;EXIT WHEN the_cursor%NOTFOUND;DBMS_OUTPUT.PUT_LINE(matching_title);END LOOP;CLOSE the_cursor;END;/show errors;-- Insert and query data.INSERT INTO books VALUES ('A1111', 'Moby Dick', 'Melville', 'Herman', 10);INSERT INTO books VALUES ('A2222', 'Get Rich Really Fast', 'Scammer', 'Ima', 1);INSERT INTO books VALUES ('A3333', 'Finding Inner Peace', 'Blissford', 'Serenity',null);INSERT INTO books VALUES ('A4444', 'Great Mystery Stories', 'Whodunit', 'Rodney',5);2-12 <strong>SQL</strong> <strong>Developer</strong> Online Help
Script for Creating and Using the Library Tutorial ObjectsINSERT INTO books VALUES ('A5555', 'Software Wizardry', 'Abugov', 'D.', 10);INSERT INTO patrons VALUES (patron_id_seq.nextval,'Smith', 'Jane', '123 Main Street', 'Mytown, MA 01234', null);INSERT INTO patrons VALUES (patron_id_seq.nextval,'Chen', 'William', '16 S. Maple Road', 'Mytown, MA 01234', null);INSERT INTO patrons VALUES (patron_id_seq.nextval,'Fernandez', 'Maria', '502 Harrison Blvd.', 'Sometown, NH 03078', null);INSERT INTO patrons VALUES (patron_id_seq.nextval,'Murphy', 'Sam', '57 Main Street', 'Mytown, MA 01234', null);INSERT INTO transactions (patron_id, book_id,transaction_date, transaction_type)VALUES (100, 'A1111', SYSDATE, 1);INSERT INTO transactions (patron_id, book_id,transaction_date, transaction_type)VALUES (100, 'A2222', SYSDATE, 2);INSERT INTO transactions (patron_id, book_id,transaction_date, transaction_type)VALUES (101, 'A3333', SYSDATE, 3);INSERT INTO transactions (patron_id, book_id,transaction_date, transaction_type)VALUES (101, 'A2222', SYSDATE, 1);INSERT INTO transactions (patron_id, book_id,transaction_date, transaction_type)VALUES (102, 'A3333', SYSDATE, 1);INSERT INTO transactions (patron_id, book_id,transaction_date, transaction_type)VALUES (103, 'A4444', SYSDATE, 2);INSERT INTO transactions (patron_id, book_id,transaction_date, transaction_type)VALUES (100, 'A4444', SYSDATE, 1);INSERT INTO transactions (patron_id, book_id,transaction_date, transaction_type)VALUES (102, 'A2222', SYSDATE, 2);INSERT INTO transactions (patron_id, book_id,transaction_date, transaction_type)VALUES (102, 'A5555', SYSDATE, 1);INSERT INTO transactions (patron_id, book_id,transaction_date, transaction_type)VALUES (101, 'A2222', SYSDATE, 1);-- Test the view and the procedure.SELECT * FROM patrons_trans_view;CALL list_a_rating(10);Tutorial: Creating Objects for a Small Database 2-13
- Page 1 and 2:
Oracle SQL DeveloperOnline HelpRele
- Page 3 and 4:
Contents1 SQL Developer Concepts an
- Page 5 and 6:
3.12 Create/Edit Index ............
- Page 7 and 8: 6.3.2 Updating Data With the UPDATE
- Page 9: 10.2.5 SQL*Plus SET Commands.......
- Page 12 and 13: SQL Developer User InterfaceThe men
- Page 14 and 15: SQL Developer User InterfaceThe Com
- Page 16 and 17: Database Objects1.2 Database Object
- Page 18 and 19: Database Objectscontaining the mast
- Page 20 and 21: Database Objects■■■■■■
- Page 22 and 23: Database ConnectionsWhen you start
- Page 24 and 25: Running and Debugging Functions and
- Page 26 and 27: Using the SQL WorksheetRelated Topi
- Page 28 and 29: Using the SQL WorksheetScript Runne
- Page 30 and 31: Using the SQL Worksheetmentioned in
- Page 32 and 33: Reports1.9 ReportsRelated TopicsRun
- Page 34 and 35: Reports1.9.3 Table reportsTable rep
- Page 36 and 37: Reportsissues and vulnerabilities,
- Page 38 and 39: SQL Developer Preferencesand the SQ
- Page 40 and 41: SQL Developer Preferences1.10.3 Cod
- Page 42 and 43: SQL Developer PreferencesSQL Develo
- Page 44 and 45: SQL Developer User Information: Loc
- Page 46 and 47: Supplementary Oracle Database Infor
- Page 48 and 49: Creating a Table (Books)the table t
- Page 50 and 51: Creating a Table (Transactions)Colu
- Page 52 and 53: Creating a SequenceName: for_key_bo
- Page 54 and 55: Creating a PL/SQL Procedure2.6 Crea
- Page 56 and 57: Using the SQL Worksheet for Queries
- Page 60 and 61: Script for Creating and Using the L
- Page 62 and 63: Check for UpdatesTo remove the effe
- Page 64 and 65: Select Library3.8 Select LibraryThi
- Page 66 and 67: Create PL/SQL Function, Procedure,
- Page 68 and 69: Create Table (quick creation)Relate
- Page 70 and 71: Create/Edit Table (with advanced op
- Page 72 and 73: Create/Edit Table (with advanced op
- Page 74 and 75: Create/Edit Table (with advanced op
- Page 76 and 77: Create/Edit Table (with advanced op
- Page 78 and 79: Create Type (User-Defined)For more
- Page 80 and 81: Create/Edit ViewTest Syntax: Checks
- Page 82 and 83: Configure File Type AssociationsDia
- Page 84 and 85: Find/Replace TextTo add a type of o
- Page 86 and 87: Save/Save As3.37 Save/Save As3.38 S
- Page 88 and 89: SQL*Plus Location3-28 SQL Developer
- Page 90 and 91: Managing TablesTo include lowercase
- Page 92 and 93: Managing Tables4.2.4 Column Constra
- Page 94 and 95: Managing Indexes4.3 Managing Indexe
- Page 96 and 97: Managing Indexesuseful when all of
- Page 98 and 99: Managing Views4.4 Managing Views4.3
- Page 100 and 101: Managing Synonyms4-12 SQL Developer
- Page 102 and 103: Storing Numeric Data■■NCHAR and
- Page 104 and 105: Storing Numeric DataThe absence of
- Page 106 and 107: Storing Datetime Data5.4.1.2 Using
- Page 108 and 109:
Storing Datetime Data5-8 SQL Develo
- Page 110 and 111:
Retrieving Data With Queries■■
- Page 112 and 113:
Retrieving Data With QueriesSee Als
- Page 114 and 115:
Retrieving Data With QueriesSee Als
- Page 116 and 117:
Transaction Control Statements6.3.2
- Page 118 and 119:
Using Pseudocolumns, Sequences, and
- Page 120 and 121:
Using Pseudocolumns, Sequences, and
- Page 122 and 123:
Using Pseudocolumns, Sequences, and
- Page 124 and 125:
Using SQL Data Definition Language
- Page 126 and 127:
Using SQL Data Definition Language
- Page 128 and 129:
Entering and Executing PL/SQL CodeY
- Page 130 and 131:
Utilizing the Main Features of PL/S
- Page 132 and 133:
Utilizing the Main Features of PL/S
- Page 134 and 135:
Utilizing the Main Features of PL/S
- Page 136 and 137:
Utilizing the Main Features of PL/S
- Page 138 and 139:
Utilizing the Main Features of PL/S
- Page 140 and 141:
Utilizing the Main Features of PL/S
- Page 142 and 143:
Utilizing the Main Features of PL/S
- Page 144 and 145:
Utilizing the Main Features of PL/S
- Page 146 and 147:
Utilizing the Main Features of PL/S
- Page 148 and 149:
Handling PL/SQL ErrorsTo handle une
- Page 150 and 151:
Handling PL/SQL ErrorsIf you redecl
- Page 152 and 153:
Handling PL/SQL Errors7-26 SQL Deve
- Page 154 and 155:
Overview of Packages and Subprogram
- Page 156 and 157:
Managing Packagescalling procedures
- Page 158 and 159:
Oracle Product-Specific PackagesTab
- Page 160 and 161:
Oracle Product-Specific PackagesTab
- Page 162 and 163:
Oracle Product-Specific Packages8-1
- Page 164 and 165:
Overview of Triggers9.1.1 Types of
- Page 166 and 167:
Overview of Triggers■■A trigger
- Page 168 and 169:
Designing TriggersNote: A procedure
- Page 170 and 171:
Using SQL*Plus■■■Running Scri
- Page 172 and 173:
Using SQL*PlusA SQL script file is
- Page 174 and 175:
Using SQL*Plus10-6 SQL Developer On
- Page 176 and 177:
Overview of Globalization Support
- Page 178 and 179:
Setting up the Globalization Suppor
- Page 180 and 181:
Setting up the Globalization Suppor
- Page 182 and 183:
Setting up the Globalization Suppor
- Page 184 and 185:
Setting up the Globalization Suppor
- Page 186 and 187:
Setting up the Globalization Suppor
- Page 188 and 189:
Setting up the Globalization Suppor
- Page 190 and 191:
Setting up the Globalization Suppor
- Page 192 and 193:
SQL and PL/SQL Programming with Uni
- Page 194 and 195:
SQL and PL/SQL Programming with Uni
- Page 196 and 197:
Locale-Dependent SQL Functions with
- Page 198 and 199:
Locale-Dependent SQL Functions with
- Page 200 and 201:
COLLECTION_IS_NULL exception, 7-22c
- Page 202 and 203:
overview, 7-14EXPLAIN PLANexecution
- Page 204 and 205:
NLSSORT SQL function, 11-21NO_DATA_
- Page 206 and 207:
displaying output from PL/SQL, 7-9s
- Page 208:
disabling, 9-4enabling, 9-4error co