Oracle变量 [英] Oracle variables

查看:59
本文介绍了Oracle变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个Oracle查询,该查询在查询之前设置了一些变量,然后可以在查询中引用该变量.

I am trying to write an Oracle query that has some variables set before the query which i can then reference within the query.

我可以在SQL Server中执行以下操作:

I can do the below in SQL Server:

DECLARE @ReviewID as VARCHAR(3)
DECLARE @ReviewYear AS VARCHAR(4)

SET @ReviewID = 'SAR'
SET @ReviewYear = '1011'

select * from table1 where review_id = @ReviewID and acad_period = @reviewyear

Oracle等同于上面的什么?我尝试使用游标和绑定变量,但是显然这些方法都无法正常工作.

What is the Oracle equivalent of the above? I have tried cursors and bind variables but am obviously doing something wrong as these methods aren't working.

Oracle查询旨在进入SSIS中的OLEDB源,然后从程序包级变量中设置变量.

The Oracle query is intended to go into an OLEDB Source in SSIS and the variables will then be set from package level variables.

推荐答案

如果要在OleDb源变量中使用此查询,则可能需要使用表达式而不是SQL变量.因此,您将按照

If you're going to be using this query in an OleDb Source from variable, you'll likely need to use an Expression as opposed to SQL variables. So you'd build the SQL statement along the lines of

"select * from table1 where review_id = " + @[User::ReviewID] + " and acad_period = " + @[User::ReviewYear]

这篇关于Oracle变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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