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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5183539/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 22:55:32  来源:igfitidea点击:

Peoplecode, SQLEXEC not retrieving correct data

oracletoadpeoplesoft

提问by Raghav Bali

<-------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?

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

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

我的查询类似于以下示例查询: 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.

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

回答by PeopleSoftTipster

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

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

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.

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

回答by Raghav Bali

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.

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

回答by WayneH

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

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

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 * ...”吗?您的表中有多少列?既然你提到了 where 子句,是你的陈述

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.

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

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.

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