Sha256: a6ba077bdb04b4d0a04bcb28825dbe88d00395eee4805b70c586e790e5a856b0

Contents?: true

Size: 1.19 KB

Versions: 124

Compression:

Stored size: 1.19 KB

Contents

= Stored Procedures in MSSQL

This guide documents the workaround implemented to allow executing stored procedures
in MSSQL, as well as getting the value of output variables.

== Simple Execution

The following stored procedure is used as an example:

  CREATE PROCEDURE dbo.SequelTest(
    @Input varchar(25),
    @Output int OUTPUT
  )
  AS
    SET @Output = LEN(@Input)
    RETURN 0

Execute it as follows:

  DB.call_mssql_sproc(:SequelTest, {args: ['Input String', :output]})

Use the +:output+ symbol to denote an output variable. The result will contain a
hash of the output variables, as well as the result code and number of affected rows:

  {:result => 0, :numrows => 1, :var1 => "1"}

Output variables will be strings by default. To specify their type, include the
SQL type:

  DB.call_mssql_sproc(:SequelTest, {args: ['Input String', [:output, 'int']]})

Result:

  {:result => 0, :numrows => 1, :var1 => 1}

Output variables will be named +var#{n}+ where n is their zero indexed position
in the parameter list. To name the output variable, include their name:

  DB.call_mssql_sproc(:SequelTest, {args: ['Input String', [:output, nil, 'Output']]})

Result:

  {:result => 0, :numrows => 1, :output => "1"}

Version data entries

124 entries across 107 versions & 2 rubygems

Version Path
sequel-5.83.1 doc/mssql_stored_procedures.rdoc
sequel-5.83.0 doc/mssql_stored_procedures.rdoc
sequel-5.82.0 doc/mssql_stored_procedures.rdoc
sequel-5.81.0 doc/mssql_stored_procedures.rdoc
sequel-5.80.0 doc/mssql_stored_procedures.rdoc
sequel-5.79.0 doc/mssql_stored_procedures.rdoc
sequel-5.78.0 doc/mssql_stored_procedures.rdoc
sequel-5.77.0 doc/mssql_stored_procedures.rdoc
sequel-5.76.0 doc/mssql_stored_procedures.rdoc
sequel-5.75.0 doc/mssql_stored_procedures.rdoc
sequel-5.74.0 doc/mssql_stored_procedures.rdoc
sequel-5.73.0 doc/mssql_stored_procedures.rdoc
sequel-5.72.0 doc/mssql_stored_procedures.rdoc
sequel-5.71.0 doc/mssql_stored_procedures.rdoc
sequel-5.70.0 doc/mssql_stored_procedures.rdoc
sequel-5.69.0 doc/mssql_stored_procedures.rdoc
sequel-5.68.0 doc/mssql_stored_procedures.rdoc
sequel-5.67.0 doc/mssql_stored_procedures.rdoc
sequel-5.66.0 doc/mssql_stored_procedures.rdoc
sequel-5.65.0 doc/mssql_stored_procedures.rdoc