# wire.data.StoredProcedure

## Parameter Class

| Property  | Type             | Description                                                                                 |
| --------- | ---------------- | ------------------------------------------------------------------------------------------- |
| EventName | string           | Parameter name alias used to map a parameter to another parameter or field in another query |
| Name      | string           | Parameter name                                                                              |
| Value     | string \| number | Parameter value                                                                             |

## Properties

| Name   | Type   | Default | Description                                           |
| ------ | ------ | ------- | ----------------------------------------------------- |
| Name   | object | null    | The name of the stored procedure in the data service. |
| Params | \[ ]   | null    | An array of parameters for the stored procedure.      |

## Methods

| Name                | Description                                                                                                                   |
| ------------------- | ----------------------------------------------------------------------------------------------------------------------------- |
| cast                | Static method that casts an object with the same stored procedure properties into an instance of the `StoredProcedure` class. |
| eventName           | Adds an event name to a parameter                                                                                             |
| getParam(param)     | Returns the parameter object named `param`.                                                                                   |
| param(param, value) | Adds a value to a parameter using the chained method `procedure`.                                                             |

If a service provider supports executing stored procedures, it will set the [allow.storedProcedure](/wirebootstrap/reference/wire.data/wire.data.datasource.md#allow) attribute to `true`.

```javascript
const allowSprocs = accountService.allow().storedProcedure;
```

The following creates a new `StoredProcedure` object which will call the  stored procedure `spGetUsers` in the data service with a parameter `User` equal to `apeters`.

```javascript
const proc = wire.data.procedure("spGetUsers")
    .param("User", "apeters");
```

The following gets the stored procedure parameter object `UserName`.

```javascript
const param = proc.getParam("UserName");
```

The following is a [TypeScript](https://www.typescriptlang.org) example that executes the stored procedure in the data service.

```javascript
...

const dataTable = await accountService.execAsync(proc);
```

Visit [Creating Queries - Stored Procedures](/wirebootstrap/creating-queries/stored-procedures.md) for more details and examples.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wirebootstrap.com/wirebootstrap/reference/wire.data/wire.data.storedprocedure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
