SQL stored procedures are an executable program module that can be stored in a database as various objects. In other words, this is an object that contains SQL statements. These stored procedures can be executed in the application client to get good performance. In addition, such objects are often called from other scripts or even from some other section.
Introduction
, (, MS SQL). , . , . , . , DDL DML, ( – UDF).
SQL , . , , – , , . 2005-2010 , "" «SQL Server Management Studio». , . . MS SQL Server , , «» , «».
. : , , . DDL-, . , . .
. , , PL/SQL Oracle, PSQL InterBase Firebird, «» Transact-SQL. , . , , , , , , .
. , , . , , . . , SQL: , , .
, . , . , .
SQL . , ( ) SQL. , (, , ) , , SQL, , :
- Output;
- ;
- .
, .
1. EXEC- SQL
MS SQL (Managment Studio). , , . SQL EXEC-, .
, , . . (), , , .
, , , . , Microsoft SQL Server. .
, , , , . , .
SQL, , , , . . :
- - ;
- ;
- .
2.
, . . .
, , . , @. , . , @NAME1 . . , , .
: « ?» . , , . : , «Select Var = ». , .
3. SQL
. , , ( ). , . , , , . , , Pubs, . , , Google SQL SQL2005.
, @State @City. , . @TotalAuthors ( ), . , . , .
SQL
. , , . , ( ). @State @City. . . , . .
. , , . @City , @State . . SQL . , , «UT» «». @City, @State «». , . , , .
4. SQL Server:
. :
- ;
- ;
- .
4.1 SQL
. . , , . , , .
, , . , . , Select-, , Select @RetValue, OutputValue.
4.2 SQL
, . Output . - «Output» . , . SQL, , .
: @TotalAuthors @TotalNoContract. . . , , .
, , , MS SQL Server . «CA». , , . , . , , , , .
4.3 SQL
(RecordSet) . SQL @AuthID «» @AuthId. Select , . AuthId . . - . , .
, , . , ( ) . SQL, , , . T SQL, , . , , , , , .