> 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/server-programming/spi/spi-interface/spi-spi-register-trigger-data.md).

# SPI\_register\_trigger\_data

### SPI\_register\_trigger\_data

SPI\_register\_trigger\_data — 讓 SPI 查詢可使用暫時性觸發程序資料

### 語法

```

int SPI_register_trigger_data(TriggerData *tdata)
```

### 說明

`SPI_register_trigger_data` 讓觸發程序擷取的任何暫時性關聯可供透過目前 SPI 連線規劃及執行的查詢使用。目前，這表示透過 `REFERENCING OLD/NEW TABLE AS` ... 子句所定義的 `AFTER` 觸發程序擷取的轉換資料表。PL 觸發程序處理函式應在連線後呼叫此函式。

### 引數

`TriggerData *tdata` : 作為 `fcinfo->context` 傳遞至觸發程序處理函式的 `TriggerData` 物件

### 回傳值

命令成功執行時會回傳下列非負值：

`SPI_OK_TD_REGISTER` : 已成功註冊擷取的觸發程序資料（若有）

發生錯誤時，會回傳下列其中一個負值：

`SPI_ERROR_ARGUMENT` : *`tdata`* 為 `NULL`

`SPI_ERROR_UNCONNECTED` : 從未連線的 C 函式呼叫

`SPI_ERROR_REL_DUPLICATE` : 任何觸發程序資料暫時性關聯的名稱已為此連線註冊

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/spi-spi-register-trigger-data.html)（原文版本：18.6；核對日期：2026-09-06）


---

# 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/server-programming/spi/spi-interface/spi-spi-register-trigger-data.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.
