使用Oracle OLE DB提供程序时如何解决SQL查询参数映射问题?

时间:2020-03-05 18:52:04  来源:igfitidea点击:

尝试使用Oracle OLE DB提供程序输入带有参数的SQL查询时,出现以下错误:

Parameters cannot be extracted from the SQL command. The provider might not help to parse parameter information from the command. In that case, use the "SQL command from variable" access mode, in which the entire SQL command is stored in a variable.

  ADDITIONAL INFORMATION:

  Provider cannot derive parameter information and SetParameterInfo has not been called. (Microsoft OLE DB Provider for Oracle)

我尝试按照这里的建议进行操作,但是不太了解所需的内容:针对Oracle的参数化查询

有任何想法吗?

解决方案

回答

要扩展问题中给出的链接:

  • 创建一个包变量
  • 双击包变量名。 (这使我们可以访问变量的属性)
  • 将属性" EvaluateAsExpression"设置为true
  • 在表达式构建器中输入查询。
  • 将OLE DB源查询设置为来自变量的SQL命令

表达式构建器可以使用变量动态创建表达式,以创建"参数化查询"。
所以下面的"正常"查询:

select * from book where book.BOOK_ID = ?

可以在表达式生成器中编写为:

"select * from book where book.BOOK_ID = " + @[User::BookID]

然后,我们可以使用表达式生成器进行空处理和数据转换。