Peoplecode、SQLEXEC 未检索到正确的数据

发布于 2024-10-20 07:11:27 字数 343 浏览 5 评论 0原文

<--------人员代码------>

你好,

我有一个 SQL 查询,我尝试使用 SQLEXEC 和 SQL.fetch() 执行,但问题是,当我将值传递给参数 (:1,:2...) 时,它不会返回一行但是当我对查询本身的 where 子句中的值进行硬编码时,它会检索正确的值。 有人可以帮忙吗?

我的查询类似于以下示例查询: Select * from PS_rec1 where emplid=:1 and plan_type=:2

它不会返回任何数据,直到我对值进行硬编码。

我已经检查了后端的值,并且可以获取一些数据。此外,相同的查询在 TOAD 中运行时会检索数据。

<-------PeopleCode------>

Hi,

I have a SQL query that i have tried executing using both SQLEXEC and SQL.fetch() but the problem is, when I am passing the values to parameters (:1,:2...) it does not return a row but when I hardcode the values in the where clause of the query itself, it retrieves the correct value.
Can anybody help?

My query looks similar to the following sample query :
Select * from PS_rec1 where emplid=:1 and plan_type=:2

it returns no data till i hardcode the values.

I have checked the values at the back end and some data is there to be fetched. Moreover, the same query retrieves data when ran in TOAD.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

单身情人 2024-10-27 07:11:27

在 SQL 语句中使用绑定之前,您是否尝试过将绑定输出到日志文件?

如果绑定不起作用,但文字起作用,那么您的绑定可能不包含您期望的值。

您还可以尝试在 SQL 语句之前显式地将绑定设置为您期望的值。这将证明您传递绑定的方式工作正常。

Have you tried outputting your binds to a log file just before you use them in your SQL statement?

If the binds aren't working, but literals are, then perhaps your binds don't contain the values that you expect them to.

You could also try explicitly setting the binds to the values that you're expecting just before the SQL statement. This will prove that the way you're passing in the binds is working correctly.

萌︼了一个春 2024-10-27 07:11:27

它需要对同一记录进行另一次更新才能获取在 SQL exec 中获取的值。
我不确定问题是什么,但我想可能是以前的更新即使在显式提交之后也没有将更改写入数据库。

It required another update to the same record to get the values fetched in SQL exec.
M not sure what was the problem but i guess it might be that the previous update did not write the changes to the db even after an explicit commit.

痴梦一场 2024-10-27 07:11:27

好的,您需要将确切的 SQLExec 语句放入问题中。

但是,SQLExec 中真的有“Select * ...”吗?您的表中有多少列?既然您提到了 where 子句,那么您的语句

SQLExec("select * from PS_rec where emplid=:1 and plan_type=:2", &var1, &var2, &vartocontainthewholerow);

Which 可以在 SQL 工具(toad)中工作,但可能在 AE 或任何类型的 Peoplecode 程序中不起作用。

现在,如果您的表有三列,您不应该有这样的内容:

SQLExec("select emplid, plan_type, column3 from PS_rec where emplid = :1 and plan_type=:2", &emplidIn, &plan_typeIn, &emplidOut, &plan_typeOut, &column3Out);

请注意,表中有三列,emplid 和 plan_type 是其中的两列,您需要列出所需的所有列,而不是星号“*”。不过,选择 emplid 和 plan_type 有点愚蠢。

Ok, you need to put your exact SQLExec statement in the question.

But, do you really have "Select * ..." in a SQLExec? How many columns are in your table? Since you mention the where clause, is your statement

SQLExec("select * from PS_rec where emplid=:1 and plan_type=:2", &var1, &var2, &vartocontainthewholerow);

Which will work in a SQL tool (toad) but probably does not work in AE or any type of Peoplecode program.

Now if your table has three columns, should you not have something like this:

SQLExec("select emplid, plan_type, column3 from PS_rec where emplid = :1 and plan_type=:2", &emplidIn, &plan_typeIn, &emplidOut, &plan_typeOut, &column3Out);

Notice that with three columns in the table that emplid and plan_type are two of them, you need to list all the columns you want, not asterisks '*'. Kind of silly to select the emplid and plan_type though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文