File: mssql_stored_procedures.rdoc

package info (click to toggle)
ruby-sequel 5.63.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,408 kB
  • sloc: ruby: 113,747; makefile: 3
file content (43 lines) | stat: -rw-r--r-- 1,220 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
= 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"}