首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

Oracle 定义变量,该怎么处理

2012-05-31 
Oracle 定义变量SQL code--这是我在SQL 2005中写的SQL:create table #tb(id int,tname nvarchar(10))inser

Oracle 定义变量

SQL code
--这是我在SQL 2005中写的SQL:create table #tb(id int,tname nvarchar(10))insert into #tb    select 1,'x' union all    select 2,'y'begindeclare @i intselect @i =  count(1) from #tb where id=1 and tname='a'if @i = 0    begin        insert into #tb values (1,'a');        update #tb set tname='aa' where id=1 and tname='a'    endselect @i =  count(1) from #tb where id=2 and tname='y'if @i=0    begin        insert into #tb values (2,'y');        update #tb set tname='yy' where id=1 and tname='y'    endselect @i =  count(1) from #tb where id=1 and tname='c'if @i = 0    begin        insert into #tb values (1,'c');        update #tb set tname='cc' where id=1 and tname='c'    endendselect * from #tb

请问上面的SQL在ORACLE中应该怎么写呢?如何定义变量呢?

[解决办法]
探讨
To yf520gn:
真神奇,只是把begin拿带下面来就OK了。为什么呀?
THX,请去http://topic.csdn.net/u/20090219/13/2395780f-1b41-4e40-83a2-ad4c73e93e7d.html也回一个帖。我好一起给分。

[解决办法]
fuck
我沒跟你講定義變量寫在begin前面嗎。。。。

热点排行