> 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/client-interfaces/ecpg/ecpg-sql-commands/ecpg-sql-set-descriptor.md).

# 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) : 描述區名稱。

*`descriptor_header_item`* [#](#ECPG-SQL-SET-DESCRIPTOR-DESCRIPTOR-HEADER-ITEM) : 用來識別要設定哪個標頭資訊項目的符記。目前只支援用於設定描述區項目數量的 `COUNT`。

*`number`* [#](#ECPG-SQL-SET-DESCRIPTOR-NUMBER) : 要設定的描述區項目編號。計數從 1 開始。

*`descriptor_item`* [#](#ECPG-SQL-SET-DESCRIPTOR-DESCRIPTOR-ITEM) : 用來識別要在描述區中設定哪個資訊項目的符記。支援項目清單請參閱[第 34.7.1 節](/client-interfaces/ecpg/ecpg-descriptors.md#ECPG-NAMED-DESCRIPTORS)。

*`value`* [#](#ECPG-SQL-SET-DESCRIPTOR-VALUE) : 要儲存至描述區項目的值。可以是 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](/client-interfaces/ecpg/ecpg-sql-commands/ecpg-sql-allocate-descriptor.md), [GET DESCRIPTOR](/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)（英文原文，待翻譯）


---

# 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 dynamically by asking a question.

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

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
