|
| |
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
Topic : STORED PROCEDURE: Returning Recordsets
|
|
Author : Jignesh
|
Total Visits: 196
|
|
Published Date:
Monday, October 09, 2000
|
|
|
|
The following SQL stored procedure returns a set of rows from the
employee table where the salary is less than the value passed :
CREATE PROCEDURE empsal
(
@limit INT
)
AS
SELECT * From employee WHERE salary < @limit
To execute this stored procedure, you can use the following Active Server Pages
script:
<!-- #INCLUDE FILE="adovbs.inc" -->
<%
Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open "Provider=SQLOLEDB;UID=jignesh;PWD=friends"
Set myCommand = Server.CreateObject( "ADODB.Command" )
myCommand.ActiveConnection = Con
MyCommand.CommandType = adCmdStoredProc
MyCommand.CommandText = "empsal"
MyCommand.Parameters.Append MyCommand.CreateParameter( "returnCode", adInteger, adParamReturnValue )
MyCommand.Parameters.Append MyCommand.CreateParameter( "limit", adInteger, adParamInput )
MyCommand( "limit" ) = 5700
Set RS = MyCommand.Execute
' Display Recordset
While NOT RS.EOF
Response.Write RS( 0 ) & " - " & RS( 1 ) & "<br>"
RS.MoveNext
WEND %> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|