> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/client-interfaces/ecpg/ecpg-sql-commands/ecpg-sql-set-descriptor.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# SET DESCRIPTOR

### SET DESCRIPTOR

SET DESCRIPTOR — 在 SQL 描述區中設定資訊

### 語法

```

SET DESCRIPTOR descriptor_name descriptor_header_item = value
SET DESCRIPTOR descriptor_name VALUE number descriptor_item = value [, ...]
```

### 說明

`SET DESCRIPTOR` 會以值填入 SQL 描述區。之後，描述區通常用於在執行預備查詢時繫結參數。

此命令有兩種形式：第一種形式作用於描述區的「標頭」，它與特定資料值無關。第二種形式則為以編號識別的特定資料值指派值。

### 參數

#### *`descriptor_name`* [#](#ecpg-sql-set-descriptor-descriptor-name) <a href="#ecpg-sql-set-descriptor-descriptor-name" id="ecpg-sql-set-descriptor-descriptor-name"></a>

描述區名稱。

#### *`descriptor_header_item`* [#](#ecpg-sql-set-descriptor-descriptor-header-item) <a href="#ecpg-sql-set-descriptor-descriptor-header-item" id="ecpg-sql-set-descriptor-descriptor-header-item"></a>

用來識別要設定哪一個標頭資訊項目的符記。目前只支援 `COUNT`，用於設定描述區項目的數量。

#### *`number`* [#](#ecpg-sql-set-descriptor-number) <a href="#ecpg-sql-set-descriptor-number" id="ecpg-sql-set-descriptor-number"></a>

要設定的描述區項目編號。從 1 開始計數。

#### *`descriptor_item`* [#](#ecpg-sql-set-descriptor-descriptor-item) <a href="#ecpg-sql-set-descriptor-descriptor-item" id="ecpg-sql-set-descriptor-descriptor-item"></a>

用來識別要在描述區中設定哪一項資訊的符記。支援的項目清單請參閱[第 34.7.1 節](https://docs.postgresql.tw/19/client-interfaces/ecpg/ecpg-descriptors/ecpg-named-descriptors.md#ecpg-named-descriptors)。

#### *`value`* [#](#ecpg-sql-set-descriptor-value) <a href="#ecpg-sql-set-descriptor-value" id="ecpg-sql-set-descriptor-value"></a>

要儲存至描述區項目的值。可以是 SQL 常數或主機變數。

### 範例

```

EXEC SQL SET DESCRIPTOR indesc COUNT = 1;
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = 2;
EXEC SQL SET DESCRIPTOR indesc VALUE 1 DATA = :val1;
EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val1, DATA = 'some string';
EXEC SQL SET DESCRIPTOR indesc VALUE 2 INDICATOR = :val2null, DATA = :val2;
```

### 相容性

SQL 標準規定了 `SET DESCRIPTOR`。

### 另請參閱

[ALLOCATE DESCRIPTOR](https://docs.postgresql.tw/19/client-interfaces/ecpg/ecpg-sql-commands/ecpg-sql-allocate-descriptor.md), [GET DESCRIPTOR](https://docs.postgresql.tw/19/client-interfaces/ecpg/ecpg-sql-commands/ecpg-sql-get-descriptor.md)

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/ecpg-sql-set-descriptor.html)（原文版本：18.6；核對日期：2026-10-18）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/client-interfaces/ecpg/ecpg-sql-commands/ecpg-sql-set-descriptor.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
