PREPARE QUERY在PRO C中什么时候失败? [英] When do a PREPARE QUERY fails in PRO C?

查看:140
本文介绍了PREPARE QUERY在PRO C中什么时候失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PREPARE QUERY在PRO C中失败了什么?

When do a PREPARE QUERY fails in PRO C?

EXEC SQL AT :db_id PREPARE QUERY FROM :sql_query;

bool sql_status = (sqlca.sqlcode == OERR_ORACLE_SUCCESS);

if (sql_status)
{
}
else
{
}

我没有这个问题,直到最近,代码工作正常PREPARE QUERY是工作正常(进入if循环,但突然它失败,并且在此之后不工作(进入else循环)。

I don't have this problem until recently, The code was working fine the PREPARE QUERY is working fine (going into if loop_, but all of a sudden it failed, and is not working after that (going into else loop).

没有任何变化,它是相同的二进制。

Nothing has changed and it's the same binary.

过去有人遇到过类似的问题吗?

does anybody faced similary problem in the past?

推荐答案

,并且随着时间的推移意识到你不想检查PREPARE语句的返回代码,因为它从不返回任何值。这是我的意思:

I've written a LOT of pro*c in the past, and over time realized that you don't want to be checking the return code of the PREPARE statement as it never returns any value. Here is what I mean:

PREPARE sqlca.sqlcode value是在PREPARE语句之前立即运行的语句的返回代码。换句话说,如果您检查PREPARE语句的输出和在PREPARE语句失败之前执行的语句,则返回代码如果上一个语句成功,则PREPARE似乎已成功。


换句话说,准备sqlca.sqlcode的值基本上没什么(它不会自己失败)。因此,如果PREPARE现在失败,请检查在PREPARE语句之前执行的语句,并确保您正在检查该语句的sqlca.sqlcode值。我打赌,上一个语句失败,返回的错误与该语句有关。有意义吗?

The PREPARE sqlca.sqlcode value is the return code of the statement that ran immediately BEFORE the PREPARE statement. In other words, if you check the output of the PREPARE statement and the statement that executed right before the PREPARE statement fails, then the return code of the prepare is failed. If the previous statement succeeded, then the PREPARE appears to have succeeded.

In other words, the prepare sqlca.sqlcode value is basically nothing (it doesn't ever fail on its own). So if the PREPARE is now failing, check the statement that executed right before the PREPARE statement and ensure you're checking the sqlca.sqlcode value of that one. My bet is that the previous statement is failing, and the error returned relates to that statement. Make sense?

-Jim

这篇关于PREPARE QUERY在PRO C中什么时候失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆