FirebirdSQL/3/Store Procedure
出自VFP Wiki
(修訂版本間差異)
DarliLatrb (對話 | 貢獻) |
小 (revert) |
||
第1行: | 第1行: | ||
- | === | + | === 存储过程是什么 === |
- | + | 預存程序(Stored Procedure)(簡稱SP)是使用者預先寫好的資料庫Script。 | |
- | + | SP最大好處是可以降低資料在網路來回傳送與網路負載,因為我們將處理資料的程式碼寫在伺服器端,那麼客戶端將只會收到經過處理後的紀錄,如此資料庫伺服器效能會大大的提升. | |
- | === | + | === 存储过程(Stored Procedure)相关語法 === |
- | * | + | *存储过程(Stored Procedure)创建的語法: |
<pre> | <pre> | ||
CREATE PROCEDURE name | CREATE PROCEDURE name | ||
- | [( param datatype [, param datatype | + | [( param datatype [, param datatype …])] |
- | [RETURNS ( param datatype [, param datatype | + | [RETURNS ( param datatype [, param datatype …])] |
AS | AS | ||
<procedure_body>; | <procedure_body>; | ||
第16行: | 第16行: | ||
<variable_declaration_list> = | <variable_declaration_list> = | ||
DECLARE VARIABLE var datatype; | DECLARE VARIABLE var datatype; | ||
- | [DECLARE VARIABLE var datatype; | + | [DECLARE VARIABLE var datatype; …] |
<block> = | <block> = | ||
BEGIN | BEGIN | ||
< compound_statement> | < compound_statement> | ||
- | [< compound_statement> | + | [< compound_statement> …] |
END | END | ||
<compound_statement> = {<block> | statement;} | <compound_statement> = {<block> | statement;} | ||
</pre> | </pre> | ||
- | *Stored Procedure | + | *Stored Procedure 修改的語法: |
<pre> | <pre> | ||
ALTER PROCEDURE name | ALTER PROCEDURE name | ||
- | [( var datatype [, var datatype | + | [( var datatype [, var datatype …])] |
- | [RETURNS ( var datatype [, var datatype | + | [RETURNS ( var datatype [, var datatype …])] |
AS | AS | ||
procedure_body; | procedure_body; | ||
</pre> | </pre> | ||
- | *Stored Procedure | + | *Stored Procedure 移除的語法: |
<pre> | <pre> | ||
DROP PROCEDURE name; | DROP PROCEDURE name; | ||
</pre> | </pre> | ||
- | === Stored Procedure | + | === Stored Procedure 範例 === |
- | *Stored Procedure | + | *Stored Procedure 建立的語法: |
- | *Stored Procedure | + | *Stored Procedure 修改的語法: |
- | *Stored Procedure | + | *Stored Procedure 移除的語法: |
- | === | + | === 相關文章 === |
- | *[http://www.aboutcase.com/phorum/read.php?f=38&i=22&t=19 | + | *[http://www.aboutcase.com/phorum/read.php?f=38&i=22&t=19 預儲程序在網站應用程式上的應用(一)] |
- | *[http://yes.nctu.edu.tw/SQL/StoredProcedure/StoredProcedure.htm | + | *[http://yes.nctu.edu.tw/SQL/StoredProcedure/StoredProcedure.htm 預存程序] |
*[http://uiproject.udngroup.com.tw/ui/TechDocs/SQL/Lessons/Implement/StoredProcedure.htm SQL Server-Stored Procedure] | *[http://uiproject.udngroup.com.tw/ui/TechDocs/SQL/Lessons/Implement/StoredProcedure.htm SQL Server-Stored Procedure] |
在2009年9月1日 (二) 01:59的最新修訂版本
目錄 |
存储过程是什么
預存程序(Stored Procedure)(簡稱SP)是使用者預先寫好的資料庫Script。
SP最大好處是可以降低資料在網路來回傳送與網路負載,因為我們將處理資料的程式碼寫在伺服器端,那麼客戶端將只會收到經過處理後的紀錄,如此資料庫伺服器效能會大大的提升.
存储过程(Stored Procedure)相关語法
- 存储过程(Stored Procedure)创建的語法:
CREATE PROCEDURE name [( param datatype [, param datatype …])] [RETURNS ( param datatype [, param datatype …])] AS <procedure_body>; <procedure_body> = [<variable_declaration_list>] <block> <variable_declaration_list> = DECLARE VARIABLE var datatype; [DECLARE VARIABLE var datatype; …] <block> = BEGIN < compound_statement> [< compound_statement> …] END <compound_statement> = {<block> | statement;}
- Stored Procedure 修改的語法:
ALTER PROCEDURE name [( var datatype [, var datatype …])] [RETURNS ( var datatype [, var datatype …])] AS procedure_body;
- Stored Procedure 移除的語法:
DROP PROCEDURE name;
Stored Procedure 範例
- Stored Procedure 建立的語法:
- Stored Procedure 修改的語法:
- Stored Procedure 移除的語法: