本文介绍了如何从libpq获取sql状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用libpq.so进行编程。我想获取在SQL Standard中称为sql state的错误代码。如何在我的C代码中获取此错误代码?

I program with libpq.so. I want to get the error code which is called sql state in SQL Standard.How should I get this in my c code?

推荐答案

查找。在 SQLSTATE 中进行搜索可在 PQresultErrorField 部分中找到 PG_DIAG_SQLSTATE

The obvious Google search for libpq get sqlstate finds the libpq-exec documentation. Searching that for SQLSTATE finds PG_DIAG_SQLSTATE in the PQresultErrorField section.

因此,您可以看到可以调用 PQresultErrorField(thePgResult,PG_DIAG_SQLSTATE)来获取 SQLSTATE

Thus, you can see that you can call PQresultErrorField(thePgResult, PG_DIAG_SQLSTATE) to get the SQLSTATE.

这篇关于如何从libpq获取sql状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 13:59