Product Documentation

FairCom C# Stored Procedures

Previous Topic

Next Topic

Returning Results

Returning a Result Set

A stored procedure may return a result set. In this case you must add columns to the result set row and then add the row to a result set.

This is accomplished as shown below:

  1. Create an instance of the SqlSpResulsetRow class by invoking the NewResultSetRow() method.

    SqlSpRow RSrow = NewResultSetRow();

  2. Set column values in a result set using the column index. For easier code writing, the generated code contains constants with the name of the result set columns and the values are the column indexes.

    RSrow[RSCol.mycolumn].Value = "";

  3. Add the row using ResultSetAddRow(SqlSpRow RSrow). Notice that this method creates a copy of the row, so the SqlSpRow object can be reused for additional rows.

A stored procedure may also have OUT parameters that must be set before returning. This is enforced by the C# language as the ExecuteSP prototype implements “out” for OUT parameters.

A stored procedure may also have INOUT parameters that may or may not be set before returning. In this case the ExecuteSP prototype implements “ref” for INOUT parameters.

Returning a UDF Result

A user-defined function is declared with a “return” value that is the return value of the ExecuteSP method.