亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ch18.htm

?? Learn SQL in an easy way...
?? HTM
?? 第 1 頁 / 共 4 頁
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"><HTML><HEAD>		<TITLE>Teach Yourself SQL in 21 Days, Second Edition -- Ch 18 -- PL/SQL: An Introduction</TITLE></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF"><CENTER><H1><IMG SRC="../buttonart/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM" BORDER="0"><BR><FONT COLOR="#000077">Teach Yourself SQL in 21 Days, Second Edition</FONT></H1></CENTER><CENTER><P><A HREF="../ch17/ch17.htm"><IMG SRC="../buttonart/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../ch19/ch19.htm"><IMGSRC="../buttonart/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../buttonart/contents.gif" WIDTH="128"HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> <HR></CENTER><CENTER><H1><FONT COLOR="#000077">- Day 18 -<BR>PL/SQL: An Introduction</FONT></H1></CENTER><H2><FONT COLOR="#000077">Objectives</FONT></H2><P>PL/SQL is the Oracle technology that enables SQL to act like a procedural language.By the end of today, you should<UL>	<LI>Have a basic understanding of PL/SQL	<P>	<LI>Understand the features that distinguish PL/SQL from standard SQL	<P>	<LI>Have an understanding of the basic elements of a PL/SQL program	<P>	<LI>Be able to write a simple PL/SQL program	<P>	<LI>Understand how errors are handled in PL/SQL programs	<P>	<LI>Be aware of how PL/SQL is used in the real world</UL><H2><FONT COLOR="#000077">Introduction</FONT></H2><P>One way to introduce PL/SQL is to begin by describing standard Structured QueryLanguage, or SQL. SQL is the language that enables relational database users to communicatewith the database in a straightforward manner. You can use SQL commands to querythe database and modify tables within the database. When you write an SQL statement,you are telling the database what you want to do, not how to do it. The query optimizerdecides the most efficient way to execute your statement. If you send a series ofSQL statements to the server in standard SQL, the server executes them one at a timein chronological order.</P><P>PL/SQL is Oracle's procedural language; it comprises the standard language ofSQL and a wide array of commands that enable you to control the execution of SQLstatements according to different conditions. PL/SQL can also handle runtime errors.Options such as loops and <TT>IF...THEN</TT> statements give PL/SQL the power ofthird-generation programming languages. PL/SQL allows you to write interactive, user-friendlyprograms that can pass values into variables. You can also use several predefinedpackages, one of which can display messages to the user.</P><P>Day 18 covers these key features of PL/SQL:<UL>	<LI>Programmers can declare variables to be used during statement processing.	<P>	<LI>Programmers can use error-handling routines to prevent programs from aborting	unexpectedly.	<P>	<LI>Programmers can write interactive programs that accept input from the user.	<P>	<LI>Programmers can divide functions into logical blocks of code. Modular programming	techniques support flexibility during the application development.	<P>	<LI>SQL statements can be processed simultaneously for better overall performance.</UL><H2><FONT COLOR="#000077">Data Types in PL/SQL</FONT></H2><P>Most data types are obviously similar, but each implementation has unique storageand internal-processing requirements. When writing PL/SQL blocks, you will be declaringvariables, which must be valid data types. The following subsections briefly describethe data types available in PL/SQL.</P><P>In PL/SQL Oracle provides subtypes of data types. For example, the data type <TT>NUMBER</TT>has a subtype called <TT>INTEGER</TT>. You can use subtypes in your PL/SQL programto make the data types compatible with data types in other programs, such as a COBOLprogram, particularly if you are embedding PL/SQL code in another program. Subtypesare simply alternative names for Oracle data types and therefore must follow therules of their associated data type.<BLOCKQUOTE>	<P><HR><FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>As in most implementations of SQL,	case sensitivity is not a factor in the syntax of a statement. PL/SQL allows either	uppercase or lowercase with its commands. <HR></BLOCKQUOTE><H3><FONT COLOR="#000077">Character String Data Types</FONT></H3><P>Character string data types in PL/SQL, as you might expect, are data types generallydefined as having alpha-numeric values. Examples of character strings are names,codes, descriptions, and serial numbers that include characters.</P><P><TT>CHAR</TT> stores fixed-length character strings. The maximum length of <TT>CHAR</TT>is 32,767 bytes, although it is hard to imagine a set of fixed-length values in atable being so long.</P><H5>SYNTAX:</H5><PRE><FONT COLOR="#0066FF">CHAR ( max_length )</FONT></PRE><P>Subtype: <TT>CHARACTER</TT></P><P><TT>VARCHAR2</TT> stores variable-length character strings. You would normallyuser <TT>VARCHAR2</TT> instead of <TT>CHAR </TT>to store variable-length data, suchas an individual's name. The maximum length of <TT>VARCHAR2</TT> is also 32,767 bytes.</P><H5>SYNTAX:</H5><PRE><FONT COLOR="#0066FF">VARCHAR2 ( max_length )</FONT></PRE><P>Subtypes: <TT>VARCHAR</TT>, <TT>STRING</TT></P><P><TT>LONG</TT> also stores variable-length character strings, having a maximumlength of 32,760 bytes. <TT>LONG</TT> is typically used to store lengthy text suchas remarks, although <TT>VARCHAR2</TT> may be used as well.<H3><FONT COLOR="#000077">Numeric Data Types</FONT></H3><P><TT>NUMBER</TT> stores any type of number in an Oracle database.</P><H5>SYNTAX:</H5><PRE><FONT COLOR="#0066FF">NUMBER ( max_length )</FONT></PRE><P>You may specify a <TT>NUMBER</TT>'s data precision with the following syntax:</P><PRE><FONT COLOR="#0066FF">NUMBER (precision, scale)</FONT></PRE><P>Subtypes: <TT>DEC</TT>, <TT>DECIMAL</TT>, <TT>DOUBLE PRECISION</TT>, <TT>INTEGER</TT>,<TT>INT</TT>, <TT>NUMERIC</TT>, <TT>REAL</TT>, <TT>SMALLINT</TT>, <TT>FLOAT</TT></P><P><TT>PLS_INTEGER</TT> defines columns that may contained integers with a sign,such as negative numbers.<H3><FONT COLOR="#000077">Binary Data Types</FONT></H3><P>Binary data types store data that is in a binary format, such as graphics or photographs.These data types include <TT>RAW</TT> and <TT>LONGRAW</TT>.<H3><FONT COLOR="#000077">The DATE Data Type</FONT></H3><P><TT>DATE</TT> is the valid Oracle data type in which to store dates. When youdefine a column as a <TT>DATE</TT>, you do not specify a length, as the length ofa <TT>DATE</TT> field is implied. The format of an Oracle date is, for example, 01-OCT-97.<H3><FONT COLOR="#000077">BOOLEAN</FONT></H3><P><TT>BOOLEAN</TT> stores the following values: <TT>TRUE</TT>, <TT>FALSE</TT>, and<TT>NULL</TT>. Like <TT>DATE</TT>, <TT>BOOLEAN</TT> requires no parameters when definingit as a column's or variable's data type.<H3><FONT COLOR="#000077">ROWID</FONT></H3><P><TT>ROWID</TT> is a pseudocolumn that exists in every table in an Oracle database.The <TT>ROWID</TT> is stored in binary format and identifies each row in a table.Indexes use <TT>ROWID</TT>s as pointers to data.<H2><FONT COLOR="#000077">The Structure of a PL/SQL Block</FONT></H2><P>PL/SQL is a block-structured language, meaning that PL/SQL programs are dividedand written in logical blocks of code. Within a PL/SQL block of code, processes suchas data manipulation or queries can occur. The following parts of a PL/SQL blockare discussed in this section:<UL>	<LI>The <TT>DECLARE</TT> section contains the definitions of variables and other	objects such as constants and cursors. This section is an optional part of a PL/SQL	block.	<P>	<LI>The <TT>PROCEDURE</TT> section contains conditional commands and SQL statements	and is where the block is controlled. This section is the only mandatory part of	a PL/SQL block.	<P>	<LI>The <TT>EXCEPTION</TT> section tells the PL/SQL block how to handle specified	errors and user-defined exceptions. This section is an optional part of a PL/SQL	block.</UL><BLOCKQUOTE>	<P><HR><FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>A block is a logical unit of PL/SQL	code, containing at the least a <TT>PROCEDURE</TT> section and optionally the <TT>DECLARE</TT>	and <TT>EXCEPTION</TT> sections. <HR></BLOCKQUOTE><P>Here is the basic structure of a PL/SQL block:</P><H5>SYNTAX:</H5><PRE><FONT COLOR="#0066FF">BEGIN         -- optional, denotes beginning of block  DECLARE     -- optional, variable definitions  BEGIN       -- mandatory, denotes beginning of procedure section  EXCEPTION   -- optional, denotes beginning of exception section  END         -- mandatory, denotes ending of procedure sectionEND           -- optional, denotes ending of block</FONT></PRE><P>Notice that the only mandatory parts of a PL/SQL block are the second <TT>BEGIN</TT>and the first <TT>END</TT>, which make up the <TT>PROCEDURE</TT> section. Of course,you will have statements in between. If you use the first <TT>BEGIN</TT>, then youmust use the second <TT>END</TT>, and vice versa.<H3><FONT COLOR="#000077">Comments</FONT></H3><P>What would a program be without comments? Programming languages provide commandsthat allow you to place comments within your code, and PL/SQL is no exception. Thecomments after each line in the preceding sample block structure describe each command.The accepted comments in PL/SQL are as follows:</P><H5>SYNTAX:</H5><PRE><FONT COLOR="#0066FF">-- This is a one-line comment.</FONT></PRE><PRE><FONT COLOR="#0066FF">/* This is amultiple-line comment.*/</FONT></PRE><BLOCKQUOTE>	<P><HR><FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>PL/SQL directly supports Data Manipulation	Language (DML) commands and database queries. However, it does not support Data Dictionary	Language (DDL) commands. You can generally use PL/SQL to manipulate the data within	database structure, but not to manipulate those structures. <HR></BLOCKQUOTE><H2><FONT COLOR="#000077">The DECLARE Section</FONT></H2><P>The <TT>DECLARE</TT> section of a block of PL/SQL code consists of variables,constants, cursor definitions, and special data types. As a PL/SQL programmer, youcan declare all types of variables within your blocks of code. However, you mustassign a data type, which must conform to Oracle's rules of that particular datatype, to every variable that you define. Variables must also conform to Oracle'sobject naming standards.<H3><FONT COLOR="#000077">Variable Assignment</FONT></H3><P>Variables are values that are subject to change within a PL/SQL block. PL/SQLvariables must be assigned a valid data type upon declaration and can be initializedif necessary. The following example defines a set of variables in the <TT>DECLARE</TT>portion of a block:</P><PRE><FONT COLOR="#0066FF">DECLARE  owner char(10);  tablename char(30);  bytes number(10);  today date;</FONT></PRE><H5>ANALYSIS:</H5><P>The <TT>DECLARE</TT> portion of a block cannot be executed by itself. The <TT>DECLARE</TT>section starts with the <TT>DECLARE</TT> statement. Then individual variables aredefined on separate lines. Notice that each variable declaration ends with a semicolon.</P><P>Variables may also be initialized in the <TT>DECLARE</TT> section. For example:</P><PRE><FONT COLOR="#0066FF">DECLARE  customer char(30);  fiscal_year number(2) := '97';</FONT></PRE><P>You can use the symbol <TT>:=</TT> to initialize, or assign an initial value,to variables in the <TT>DECLARE</TT> section. You must initialize a variable thatis defined as <TT>NOT NULL</TT>.</P><PRE><FONT COLOR="#0066FF">DECLARE  customer char(30);  fiscal_year number(2) NOT NULL := '97';</FONT></PRE><H5>ANALYSIS:</H5><P>The <TT>NOT NULL</TT> clause in the definition of <TT>fiscal_year</TT> resemblesa column definition in a <TT>CREATE TABLE</TT> statement.<H3><FONT COLOR="#000077">Constant Assignment</FONT></H3><P>Constants are defined the same way that variables are, but constant values arestatic; they do not change. In the previous example, <TT>fiscal_year</TT> is probablya constant.<BLOCKQUOTE>	<P><HR><FONT COLOR="#000077"><B>NOTE:</B></FONT><B> </B>You must end each variable declaration	with a semicolon. <HR></BLOCKQUOTE><H3><FONT COLOR="#000077">Cursor Definitions</FONT></H3><P>A cursor is another type of variable in PL/SQL. Usually when you think of a variable,a single value comes to mind. A cursor is a variable that points to a row of datafrom the results of a query. In a multiple-row result set, you need a way to scrollthrough each record to analyze the data. A cursor is just that. When the PL/SQL blocklooks at the results of a query within the block, it uses a cursor to point to eachreturned row. Here is an example of a cursor being defined in a PL/SQL block:</P><H5>INPUT:</H5><PRE><FONT COLOR="#0066FF"><B>DECLARE cursor employee_cursor is    select * from employees;</B></FONT></PRE><P>A cursor is similar to a view. With the use of a loop in the <TT>PROCEDURE</TT>section, you can scroll a cursor. This technique is covered shortly.<H3><FONT COLOR="#000077">The %TYPE Attribute</FONT></H3><P><TT>%TYPE</TT> is a variable attribute that returns the value of a given columnof a table. Instead of hard-coding the data type in your PL/SQL block, you can use<TT>%TYPE</TT> to maintain data type consistency within your blocks of code.</P><H5>INPUT:</H5><PRE><FONT COLOR="#0066FF"><B>DECLARE  cursor employee_cursor is    select emp_id, emp_name from employees;  id_num employees.emp_id%TYPE;  name employees.emp_name%TYPE;</B></FONT></PRE><H5>ANALYSIS:</H5><P>The variable <TT>id_num</TT> is declared to have the same data type as <TT>emp_id</TT>in the <TT>EMPLOYEES</TT> table. <TT>%TYPE</TT> declares the variable <TT>name</TT>to have the same data type as the column <TT>emp_name</TT> in the <TT>EMPLOYEES</TT>table.<H3><FONT COLOR="#000077">The %ROWTYPE Attribute</FONT></H3><P>Variables are not limited to single values. If you declare a variable that isassociated with a defined cursor, you can use the <TT>%ROWTYPE</TT> attribute todeclare the data type of that variable to be the same as each column in one entirerow of data from the cursor. In Oracle's lexicon the <TT>%ROWTYPE</TT> attributecreates a record variable.</P><H5>INPUT:</H5><PRE><FONT COLOR="#0066FF"><B>DECLARE  cursor employee_cursor is    select emp_id, emp_name from employees;  employee_record employee_cursor%ROWTYPE;</B></FONT></PRE><H5>ANALYSIS:</H5><P>This example declares a variable called <TT>employee_record.</TT> The <TT>%ROWTYPE</TT>attribute defines this variable as having the same data type as an entire row ofdata in the <TT>employee_cursor</TT>. Variables declared using the <TT>%ROWTYPE</TT>attribute are also called aggregate variables.<H3><FONT COLOR="#000077">The %ROWCOUNT Attribute</FONT></H3>

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99re这里都是精品| gogo大胆日本视频一区| 国产精品伦理一区二区| 精品久久久三级丝袜| 在线成人高清不卡| 欧美久久久久久蜜桃| 精品污污网站免费看| 91麻豆123| 欧美亚洲图片小说| 欧美精品成人一区二区三区四区| 欧美亚洲动漫另类| 欧美人妇做爰xxxⅹ性高电影 | 日韩电影在线一区二区三区| 亚洲午夜视频在线观看| 性做久久久久久免费观看欧美| 亚洲444eee在线观看| 人禽交欧美网站| 蜜桃av一区二区三区| 国产中文字幕精品| 不卡在线观看av| 色94色欧美sute亚洲线路一久| 欧美综合天天夜夜久久| 91精品国产一区二区| 精品噜噜噜噜久久久久久久久试看| 精品国产99国产精品| 国产精品麻豆99久久久久久| 亚洲色欲色欲www| 日韩精品色哟哟| 另类专区欧美蜜桃臀第一页| 国产精品一卡二卡| 日本丰满少妇一区二区三区| 欧美大肚乱孕交hd孕妇| 国产精品美日韩| 日本亚洲最大的色成网站www| 加勒比av一区二区| 一本大道久久a久久综合婷婷| 欧美日本一区二区三区四区| 欧美经典一区二区三区| 亚洲精品午夜久久久| 国产一区二区导航在线播放| 色88888久久久久久影院野外| 精品久久久久香蕉网| 亚洲男女毛片无遮挡| 久久99久久久欧美国产| 91极品视觉盛宴| 国产免费成人在线视频| 亚洲成a人片在线观看中文| 国产福利一区二区三区视频在线 | 久久九九影视网| 无码av中文一区二区三区桃花岛| 国产酒店精品激情| 欧美日韩在线播| 国产精品久久毛片av大全日韩| 午夜av区久久| 色视频一区二区| 成人精品电影在线观看| 免费不卡在线观看| 亚洲色欲色欲www在线观看| 日本不卡在线视频| 国产精品久久久久久福利一牛影视| 日韩成人免费看| 欧美日韩国产精品成人| 日韩av不卡一区二区| 亚洲综合色噜噜狠狠| gogogo免费视频观看亚洲一| 久久你懂得1024| 久久久久久久网| 日本大香伊一区二区三区| 欧美精品一区视频| 精品一区二区在线看| 欧美色综合久久| 亚洲一区二区三区中文字幕在线| 91视视频在线直接观看在线看网页在线看| 久久精品一区二区三区av| 国产自产高清不卡| 日韩精品在线一区二区| 美国欧美日韩国产在线播放| 欧美一区二区观看视频| 蜜臀精品久久久久久蜜臀| 欧美电视剧免费全集观看| 老司机午夜精品99久久| 久久色在线视频| 国产成人免费视频一区| 国产精品免费久久| 99久久精品国产麻豆演员表| 亚洲日本丝袜连裤袜办公室| 在线视频国产一区| 日本强好片久久久久久aaa| 欧美一区二区三区在线电影| 欧美96一区二区免费视频| 国产精品一区不卡| 国产精品一区专区| 国产精品亚洲成人| 日本最新不卡在线| 麻豆精品视频在线观看免费 | 激情综合色综合久久| 亚洲人123区| 在线亚洲高清视频| 国产精品区一区二区三区| 国产日韩欧美精品综合| 丝袜美腿亚洲色图| 国产精品女主播av| 色综合色狠狠综合色| 国产精品一二三四区| 亚洲国产精品一区二区www| 一区二区在线看| 美国一区二区三区在线播放| 另类欧美日韩国产在线| 99久久精品免费看国产| 日韩一区二区影院| 国产欧美日韩精品一区| 久久精品国产一区二区| 欧美电视剧在线观看完整版| 亚洲图片你懂的| 一区二区三区四区蜜桃| 亚洲欧洲日韩av| 国产在线不卡视频| 精品对白一区国产伦| 日韩欧美精品三级| 亚洲激情第一区| 91国在线观看| 日日骚欧美日韩| 99精品视频在线观看免费| 中文字幕一区二区三| 成人精品视频一区| 国产尤物一区二区| 蜜臀精品一区二区三区在线观看| 亚洲欧美另类久久久精品| 国产女人18毛片水真多成人如厕| 欧美大片一区二区| 国产一区二区三区日韩| 蜜臀精品久久久久久蜜臀| 国产在线日韩欧美| 成人av资源在线| 欧美三级三级三级| 在线观看91av| 国产午夜精品久久久久久免费视 | av日韩在线网站| 欧美大尺度电影在线| 亚洲精品菠萝久久久久久久| 国产精品白丝jk黑袜喷水| 亚洲精品在线一区二区| 盗摄精品av一区二区三区| 亚洲成人资源网| 51久久夜色精品国产麻豆| 不卡电影一区二区三区| 久久99精品国产麻豆婷婷洗澡| 一区二区三区在线视频观看58 | 天堂久久一区二区三区| 亚洲激情男女视频| 日韩成人一级片| 国产美女精品一区二区三区| 国产精品一级黄| 91老师国产黑色丝袜在线| 欧洲国内综合视频| 欧美精品丝袜久久久中文字幕| 538prom精品视频线放| 精品国产免费久久| 亚洲人妖av一区二区| 午夜精品爽啪视频| 精品一区二区三区免费| 成人av影视在线观看| 欧美日韩你懂得| 国产精品久久免费看| 蜜桃av噜噜一区二区三区小说| 国产精品一二三在| 日韩一二三四区| 亚洲精品高清在线观看| 亚洲一区精品在线| 精品日本一线二线三线不卡| 日韩欧美一区中文| 91精品国模一区二区三区| 欧美一区二区女人| 欧美日韩精品系列| 欧美一区二区美女| 国产性色一区二区| 中文字幕中文字幕一区二区| 亚洲成人福利片| 粉嫩久久99精品久久久久久夜| 免费精品99久久国产综合精品| 精品国产不卡一区二区三区| 久久久精品免费网站| 久久久精品一品道一区| 中文字幕一区二区三区视频| 亚洲国产精品99久久久久久久久| 亚洲欧洲www| 蜜臀久久99精品久久久画质超高清 | 蜜臀91精品一区二区三区| 色综合天天综合网天天看片| 亚洲18女电影在线观看| 一本大道久久a久久精二百| 国产精品高潮呻吟| 色综合久久久网| 午夜成人免费电影| 日韩欧美高清dvd碟片| 美女在线观看视频一区二区| 日韩一卡二卡三卡四卡| 韩国精品久久久| 亚洲综合丝袜美腿| 制服丝袜日韩国产|