> 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/the-sql-language/functions/functions-info/functions-info-validity.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 9.27.7. 資料有效性檢查函式

## 9.27.7. 資料有效性檢查函式 [#](#functions-info-validity) <a href="#functions-info-validity" id="functions-info-validity"></a>

[表 9.83](#functions-info-validity-table) 所列的函式有助於檢查擬輸入資料的有效性。

### 表 9.83. 資料有效性檢查函式 [#](#functions-info-validity-table) <a href="#functions-info-validity-table" id="functions-info-validity-table"></a>

<table data-header-hidden><thead><tr><th></th></tr></thead><tbody><tr><td><p>函式</p><p>說明</p><p>範例</p></td></tr><tr><td><p><code>pg_input_is_valid</code> ( <em><code>string</code></em> <code>text</code>, <em><code>type</code></em> <code>text</code> ) → <code>boolean</code></p><p>測試給定的 <em><code>string</code></em> 對於指定的資料型別而言是否為有效的輸入，並回傳 true 或 false。</p><p>只有在該資料型別的輸入函式已經更新為將無效輸入以「軟性」錯誤回報時，這個函式才能如預期般運作。否則，無效的輸入會中止交易，就如同直接將字串轉型為該型別一樣。</p><p><code>pg_input_is_valid('42', 'integer')</code> → <code>t</code></p><p><code>pg_input_is_valid('42000000000', 'integer')</code> → <code>f</code></p><p><code>pg_input_is_valid('1234.567', 'numeric(7,4)')</code> → <code>f</code></p></td></tr><tr><td><p><code>pg_input_error_info</code> ( <em><code>string</code></em> <code>text</code>, <em><code>type</code></em> <code>text</code> ) → <code>record</code> ( <em><code>message</code></em> <code>text</code>, <em><code>detail</code></em> <code>text</code>, <em><code>hint</code></em> <code>text</code>, <em><code>sql_error_code</code></em> <code>text</code> )</p><p>測試給定的 <em><code>string</code></em> 對於指定的資料型別而言是否為有效的輸入；如果不是，則回傳原本會拋出之錯誤的詳細資訊。如果輸入有效，結果為 NULL。其輸入與 <code>pg_input_is_valid</code> 相同。</p><p>只有在該資料型別的輸入函式已經更新為將無效輸入以「軟性」錯誤回報時，這個函式才能如預期般運作。否則，無效的輸入會中止交易，就如同直接將字串轉型為該型別一樣。</p><p><code>SELECT * FROM pg_input_error_info('42000000000', 'integer')</code> →</p><pre><code>                       message                        | detail | hint | sql_error_code
------------------------------------------------------+--------+------+----------------
 value "42000000000" is out of range for type integer |        |      | 22003
</code></pre></td></tr></tbody></table>

<br>

[返回 9.27. 系統資訊函式與運算子](https://docs.postgresql.tw/19/the-sql-language/functions/functions-info.md#functions-info)

***

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


---

# 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/the-sql-language/functions/functions-info/functions-info-validity.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.
