,,,
. ().
, , .
, . 1974 SQL IBM System R ( -), ( ) SQL/DS (1981 ) DB2 (1983 ), SQL 1987 .
SQL , , ( 30) . SQL ( ) ( ).
SQL, , . SQL , , , , , . , , .
, SQL. , (, ), SQL. , , SQL, () .
SQL .
SQL SQL. .
. , , .
SQL Oracle V.6.
SQL/89 , .
, SQL, , . SQL/89 - . SQL .
SQL, SQL. SQL " ". SQL , SQL , .
. , SQL SQL. SQL, SQL, SQL -. SQL , ( , ). .. SQL SQL , .
, SQL, , ( , ).
, . , SQL . - .
, . , . , , SQL . SQL "" . , . PL- , .
SQL SQL/89 :
<module> ::=
<module name clause>
<language clause>
<module autorization clause>
[<declare cursor>...]
< procedure > ...
<module name clause> ::= MODULE [<module name>]
<language clause> ::= LANGUAGE { COBOL | FORTRAN | PASCAL | PLI }
<module autorization clause> ::=
AUTHORIZATION <module autorization identifier>
<module autorization identifier> ::= <autorization identifier>
, SQL , . , . , - , , SQL.
1.1.2.
SQL :
<procedure> ::=
PROCEDURE <procedure name>
<parameter declaration>...;
<SQL statment>;
<parameter declaration>::=
<parameter name> <data type>
| <SQLCODE parameter>
<SQLCODE parameter> ::= SQLCODE
<SQL statement> ::=
<close statement>
| <commit statement>
| <delete statement positioned>
| <delete statement searched>
| <fetch statement>
| <insert statement>
| <open statement>
| <rollback statement>
| <select statement>
| <update statement positioned>
| <update statement searched>
. , SQL , . , . SQLCODE ( ; , ).
SQL/89 ( ) SQL , , . " " .
<embedded SQL statement> ::=
<SQL prefix>
{ <declare cursor>
| <embedded exception declaration>
| <SQL statement>}
[<SQL terminator>]
<SQL prefix> ::= EXEC SQL
<SQL terminator> ::= END EXEC | ;
<embedded SQL declare section> ::=
<embedded SQL begin declare>
(<host variable definition>...]
<embedded SQL end declare>
<embedded SQL begin declare> ::=
<SQL prefix> BEGIN DECLARE SECTION [<SQL terminator>]
<embedded SQL end declare> ::=
<SQL prefix> END DECLARE SECTION [<SQL terminator>]
<embedded variable name> ::= :<host identifier>
<embedded exception declaration> ::=
WHENEVER <condition> <exception action>
<condition> ::= SQLERROR | NOT FOUND
<exception action> ::= CONTINUE | <go to>
<go to> ::= { GOTO | GO TO } <target>
<target> ::= :<host identifier> | <unsigned integer>
SQL, , , EXEC SQL END EXEC. , . , SQL, . , .
SQL/89 ( , ). : SQLERROR - SQLCODE ; NOT FOUND - SQLCODE +100 ( ). ( GO TO), ( CONTINUE). , SQL.
, SQL ( ): SQLCODE , SQLSTATE , , . SQLSTATE, SQLCODE.
SQL/89 . , ; ; . SQL, SQL. , SQL/89 SQL.
2.1. ,
, , SQL.
:
<declare cursor> ::=
DECLARE <cursor name> CURSOR FOR <cursor specification>
<cursor specification> ::=
<query expression> [<order by clause>...]
<query expression> ::=
<query term>
| <query expression> UNION [ALL] <query term>
<query term> ::= <query specification> | (<query expression>)
<order by clause> ::=
ORDER BY <sort specification>
[{,<sort specification>}...]
<sort specification> ::=
{ <unsigned integer> | <column specification> }
[ASC | DESC]
UNION . , .
:
<open statement> ::= OPEN <cursor name>
SQL , . , . . , SQL .
SQL .
.
:
<fetch statement> ::=
FETCH <cursor name> INTO <fetch target list>
<fetch target list> ::=
<target specification>[{,<target specification>}...]
INTO, ( SQL "" SQL). .
: ( ), .
, , , , , SQLCODE 100, , INTO.
, , .
r, , , r, .
SQL89 , , . , , , , , SQL : <parameter name>[INDICATOR]<parameter name> , <embedded variable name>[INDICATOR]<embedded variable name> . ( ) .
:
<delete statement: positioned> ::=
DELETE FROM <table name>
WHERE CURRENT OF <cursor name>
, , , . , FROM DELETE, , FROM .
:
<update statement: positioned> ::=
UPDATE <table name>
SET <set clause:positioned>
[{,<set clause:positioned>}...]
WHERE CURRENT OF <cursor name>
<set clause: positioned> ::=
<object column:positioned> =
{ <value expression> | NULL }
<object column: positioned> ::= <column name>
, , SET. . , FROM DELETE, , FROM .
:
<close statement> ::= CLOSE <cursor name>
, . OPEN.
2.2.
.
:
<select statement> ::=
SELECT [ALL | DISTINCT] <select name>
INTO <select target list> <table expression>
<select target list>::=
<target specification>
[{,<target specification>}...]
, , .
:
<delete statement: searched> ::=
DELETE FROM <table name>
WHERE [<search condition>]
T, FROM DELETE, . , T WHERE.
: T, , true, T. WHERE T.
:
<update statement: searched> ::=
UPDATE <table name>
SET <set clause: searched>
[{,<set clause: searched>}...]
[WHERE <search conditions>]
<set clause: searched> ::=
<object column: searched> =
{ <value expression> | NULL }
<object column: searched> ::= <column name>
T, UPDATE, . , T WHERE.
: T , , true, SET. SET T, .
( ) COMMIT WORK ( , ) ROLLBACK WORK. , .
SQL/89 SQL . "" (, , ) , - .
, SQL . , . SQL , , SQL, ( , SQL). , (, ). , , SQL , SQL , .. .
, ( ) SQL . SQL, System R, Oracle V.6 , SQL/92 SQL.
Oracle SQL , , SQL/92.
, SQL, : PREPARE, DESCRIBE EXECUTE.
3.1.
PREPARE :
<prepare-statement> ::=
PREPARE <statement-name> FROM <host-string-variable>
<statement-name> ::= <name>
PREPARE , host-string-variable, SQL, , . PREPARE PREPARE .
SQL, (.. SQL ), , PREPARE, . .
3.2.
DESCRIBE , , ( ) , (SELECT).
DESRIBE , ( ) , .
3.3.
EXECUTE SQL 'N' ( ) . EXECUTE:
<execute-statement> ::=
EXECUTE
{<statement-name> [USING <host-vars-list>]
( IMMEDIATE <host-string-variable> }
EXECUTE. <statement-name> , PREPARE. , EXECUTE <host-vars-list>. .
EXECUTE Oracle SQL 'N'. EXECUTE , SQL ( ). ( ).
3.4. SQL
SQL. -, , , PREPARE ( PREPARE DECLARE). DECLARE :
<declare cursor> ::=
DECLARE <cursor name> CURSOR
FOR { <cursor specification> | <statement-name> }
, , OPEN FETCH.
:
<open statement> ::=
OPEN <cursor name>
[USING { <host-vars-list> | DESCRIPTOR <descr-name> }]
<fetch statement> ::=
FETCH <cursor name>
{ INTO <fetch target list>
( USING <host-vars-list>
( USING DESCRIPTOR <descr-name> }
, : OPEN / FETCH , -.
, . , , .
, , . . , , -.
, SQL . IBM SQL . - ; , UNIX. /, SQL . SQL , , - .
SQL . , .
. .
. . .: , 1983. 320
.., .. . .: , 1989. 351 .
. DB2. - .: , 1988. - 320 .
. . -.: , 1991. 252 .
.. (SQL). .: , 1994. 80 .
..: . - .: , 1994. - 90 .
WEB: www.citforum.ru
SQL.ru WEB: www.SQL.ru
. . -.: , 1987. - 608 .
. . .: , 1984. 294 .
Copyright (c) 2024 Stud-Baza.ru , , , .