我似乎无法在Oracle PL/SQL where子句中使用变量.我来自Microsoft SQL Server背景,很简单.例如,执行类似以下操作所需的所有步骤是什么?
declare @var int set @var = 1
select * from SomeTable where SomeField = @var
Run Code Online (Sandbox Code Playgroud)
这看起来似乎不应该在PL/SQL中很难,但显然它是.: - /我听说我需要在PL/SQL中使用游标等?
任何帮助将不胜感激.谢谢.
这是一些示例代码:
if object_id('tempdb..#TempList') is not null drop table #TempList
create table #TempList (
ID int,
Name varchar(20)
)
insert into #TempList values (1, 'Alpha')
insert into #TempList values (2, 'Beta')
insert into #TempList values (3, 'Gamma')
insert into #TempList values (4, 'Delta')
insert into #TempList values (5, 'Omega')
select * from #TempList
if object_id('tempdb..#TempList') is not null drop table #TempList
drop table #TempList
create table #TempList (
ID_New int,
AnotherID int,
Name_New varchar(40)
)
insert into #TempList values (100, 110, …Run Code Online (Sandbox Code Playgroud)