... need:
ã A MySQL 5 server
ã A text editor such as vi, emacs, or Notepad
ã The MySQL Query Browser
You can get the MySQL server and MySQL Query Browser from http://dev .mysql. com.
Our First Stored Procedure
We’ll ... overview of creating a storedprocedure using the
MySQL Query Browser. Using the Query Browser is certainly a more user-friendly way
Example 2-2. Creating our first stored procedure
$ mysql -uroot -psecret ... 310
Using Stored Programs in JDBC 317
Stored Programs and J2EE Applications 323
Using Stored Procedures with Hibernate 332
Using Stored Procedures with Spring 337
Conclusion 342
15. Using MySQL Stored...
... cmd.CommandText = STOREDPROCEDURE_NAME;
cmd.CommandType = CommandType.StoredProcedure;
// Inserted and updated records
if (ds.HasChanges(DataRowState.Added | DataRowState.Modified)) ... = "TBL0811";
private const String STOREDPROCEDURE_NAME = "SP0811_Update";
// . . .
private void StoredProcedureMultipleRowsForm_Load(object sender,
System.EventArgs ... 8.11 Using a Single StoredProcedure to Update Multiple Changes to a SQL
Server Database
Problem
You need to update a SQL Server 2000 database with changes to multiplerows in a
DataSet by...
... loại extend stored
procedure được xem như system storedprocedure và ngược lại.
5. Remote StoredProcedure : Những storedprocedure gọi stored
procedure ở server khác.
Viết Stored Procedure
... một stored procedure.
Chúng ta hãy xem một ví dụ sau về Stored Procedure: Ðể tạo một stored
procedure bạn có thể dùng Enterprise Manager click lên trên StoredProcedure
-> New StoredProcedure ... Temporary StoredProcedure : Là những storedprocedure tương tự
như local storedprocedure nhưng chỉ tồn tại cho đến khi connection đã tạo
ra chúng bị đóng lại hoặc SQL Server shutdown. Các stored procedure...
... sql;
command.Parameters.AddWithValue("@Ma",txtMaHS.Text.Trim());
command.Parameters.AddWithValue("@Ten",txtTenHS.Text.Trim());
command.Parameters.AddWithValue("@Ns",dtNgaySinh.Value);
command.Parameters.AddWithValue("@Dc",txtDiaChi.Text.Trim());
command.Parameters.AddWithValue("@Diem",txtDiemTB.Text.Trim());
command.Parameters.AddWithValue("@Lop",cboLop.SelectedValue.ToString());
command.ExecuteNonQuery();
5. Thực thi thông qua các Stored procedure
a. Cách tạo Stored Procedure
- Tạo mới Stored Procedure, chọn New
Stored Procedure
6
... dụng được cách thực thi
các câu lệnh SQL thông qua Stored Procedure.
o StoredProcedure không có kết
quả trả về (parameter input)
o StoredProcedure có kết quả trả
về (parameter output)
2. ... thực hành NMCNPM
- Tạo StoredProcedure thêm mới thông
tin một học sinh như sau:
7
Hướng dẫn thực hành NMCNPM
HƯỚNG DẪN THỰC HÀNH TUẦN 9
Chủ đề: Gọi thực thi Stored Procedure
1. Mục đích
-...
... F2 Q10
Return
9. Using VB 6 or VB.NET to execute the ‘AddNewOrder’ storedprocedure
10. Using xp_cmdshell extended storedprocedure to send a message
(xp_cmdshell ‘net send Hello’)
Tungvn40@yahoo.com ...
VALUES(@OrderID,@ProductName,@CustomerID)
SELECT @Result=0
COMMIT TRANSACTION
END
END
Else
BEGIN
If Exists (SELECT OrderID FROM [Orders] WHERE
OrderID=@OrderID)
BEGIN
SELECT @Result=1
ROLLBACK TRANSACTION
END
Else
BEGIN
INSERT INTO ...
VALUES(@CustomerID,@CustomerName)
If Exists (SELECT OrderID FROM [Orders] WHERE
OrderID=@OrderID)
BEGIN
SELECT @Result=1
ROLLBACK TRANSACTION
END
Else
BEGIN
INSERT INTO [Orders]
(OrderID,ProductName,CustomerID)...
... the object acted upon by the stored procedure. This situation is very similar
to testing stored procedures that return a SQL rowset object.
Comments
Many stored procedures affect an underlying ... integer that identifies a rowset.
Comments
Many stored procedures return a SQL rowset object. It’s not entirely obvious how to compare an
actual rowset returned by a storedprocedure under test to ... When the Stored
Procedure Under Test Does Not Return a Value
Problem
You want to test a SQL storedprocedure that performs some action but does not return a value.
Design
Call the stored procedure...
... extend storedprocedure được xem như system storedprocedure và ngược lại.
5. Remote StoredProcedure : Những storedprocedure gọi storedprocedure ở server
khác.
6.4.3. Viết Stored Procedure
Tên ... một stored procedure. Chúng ta hãy xem một ví dụ
sau về Stored Procedure: Ðể tạo một storedprocedure bạn có thể dùng Enterprise Manager
click lên trên StoredProcedure -> New StoredProcedure ... StoredProcedure : Là những storedprocedure tương tự như local
stored procedure nhưng chỉ tồn tại cho đến khi connection đã tạo ra chúng bị đóng
lại hoặc SQL Server shutdown. Các stored procedure...
... extend storedprocedure được xem như system storedprocedure và
ngược lại.
5. Remote StoredProcedure : Những storedprocedure gọi storedprocedure ở
server khác.
6.4.3. Viết Stored Procedure
Tên ... một stored procedure. Chúng
ta hãy xem một ví dụ sau về Stored Procedure: Ðể tạo một storedprocedure bạn có thể
dùng Enterprise Manager click lên trên StoredProcedure -> New Stored
Procedure ... dùng trong stored procedures và triggers. Trước hết hãy xem qua một ví dụ về
cursor:
DECLARE @au_lname varchar(40), @au_fname varchar(20)
3. Temporary StoredProcedure : Là những stored procedure...
... contains the stored procedure.
4. Expand the Stored Procedures node.
5. Right-click on the storedprocedure to be debugged and select Step IntoStored
Procedure from the popup menu.
6. If requested, ... Step IntoStored
Procedure from the popup menu.
2. If requested, supply the parameter values on the Run StoredProcedure dialog.
Debugging a storedprocedure from managed code
To debug a stored ... Run StoredProcedure dialog.
Alternatively, if the storedprocedure is already open in a source window in Visual Studio
.NET:
1. Right-click on the storedprocedure to be debugged and select...
... this routine, called UseAStoredProcedureWithAParameter, in Listing A.8.
Listing A.8 basCommandExamples.vb: Calling a StoredProcedure By Using
Parameters
Sub UseAStoredProcedureWithAParameter(ByVal ... which in this case will
be the name of the stored procedure, called CustOrdersHist. You can see the T-SQL for
CustOrderHist in Listing A.7. This storedprocedure returns product names and the total ... A.7 Northwind SQL Server Database: T-SQL for the StoredProcedure
Called CustOrdersHist
ALTER PROCEDURE CustOrderHist @CustomerID nchar(5)
AS
SELECT ProductName, Total=SUM(Quantity)
FROM Products...
... SqlInfoMessageEventHandler(conn_InfoMessage);
// Define a storedprocedure command and the parameters.
SqlCommand cmd = new SqlCommand("SP0210_Raiserror", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@Severity", ... "MESSAGE: " + e.Message;
}
Discussion
Errors and messages are returned from a SQL Server storedprocedure to a calling
application using the RAISERROR (note the spelling) function. The error ... function, look up RAISERROR in SQL
Server Books Online.
[ Team LiB ]
// Try to execute the stored procedure.
cmd.ExecuteNonQuery( );
}
catch(System.Data.SqlClient.SqlException ex)
{...
... a data value to the storedprocedure and the storedprocedure to
pass a data value back to the caller.
Output
The parameter is an output parameter allowing the storedprocedure to
pass a ... caller.
ReturnValue The parameter represents the value returned from the stored procedure.
Return parameters from the storedprocedure used to build a DataReader are not available
until the DataReader ... LiB ]
[ Team LiB ]
Recipe 2.12 Retrieving StoredProcedure Return Values Using a DataReader
Problem
You are using a storedprocedure to create a DataReader and need to get the return...
... sau về Stored Procedure: Ðể tạo một
stored procedure bạn có thể dùng Enterprise Manager click lên trên StoredProcedure -> New
Stored Procedure Trong ví dụ này ta sẽ tạo ra một storedprocedure ... 'dir c:\' . Nhiều loại extend storedprocedure được xem như system storedprocedure
và ngược lại.
Viết StoredProcedure
Tên và những thông tin về StoredProcedure khi được tạo ra sẽ chứa ... dụ,
* Remote StoredProcedure : Những storedprocedure gọi storedprocedure ở server khác.
sp_who @loginame='DomainName\Administrators' . Có hàng trăm system storedprocedure
trong...
... than one storedprocedure at a time. It also supports filtering options and does not
require a storedprocedure Command object. Executing this procedure returns a result set
in which the rows correspond ... System stored procedure: sp_sproc_columns
The second technique is specific to Microsoft SQL Server. The system storedprocedure
sp_sproc_columns returns parameter information for one or more stored ... for the storedprocedureinto a Parameters
collection. The collection is iterated over to extract information about the parameters,
which is subsequently displayed.
If the stored procedure...
... DUNG :
Phần 1 : Tổng quan về StoredProcedure (Khái Niệm,
Phần 1 : Tổng quan về StoredProcedure (Khái Niệm,
Phân Loại Stored Procedure) .
Phân Loại Stored Procedure) .
Phần 2 : Các Ví dụ ... nạp vào bộ nhớ (
procedure
procedure
cache)
cache)
MICROSOFT STUDENT
MICROSOFT STUDENT
PARTNER 2009
PARTNER 2009
11
11
1.3.1 System Stored Procedures :
1.3.1 System Stored Procedures :
“
“
A ... 1 “System StoredProcedure
2.5 Tự tạo 1 “System StoredProcedure
Kết quả
Kết quả
:
:
MICROSOFT STUDENT
MICROSOFT STUDENT
PARTNER 2009
PARTNER 2009
6
6
1.1 Giới thiệu Stored Procedure...