当前位置: 代码迷 >> Oracle技术 >> Declare sql server 转oracle语句,该怎么处理
  详细解决方案

Declare sql server 转oracle语句,该怎么处理

热度:89   发布时间:2016-04-24 08:37:02.0
Declare sql server 转oracle语句
SQL code
Declare @sql varchar(8000)Set @sql = 'select 'Select @sql = @sql + Subject+','from (select distinct Subject from cj) as cj Set @sql=SubString(@sql,1,len(@sql)-1)Select @sql = @sql+' from table3'Exec (@sql)


------解决方案--------------------
SQL code
declare   tsql varchar2(8000);begin  tsql := ' select ';   select (tsql || Subject || ',') into tsql from (select distinct Subject from cj) as cj;  tsql := substr(tsql,1,Length(tsql)-1);  tsql := tsql || ' from table3';  execute immediate tsql;end;
------解决方案--------------------
SQL code
declare   tsql varchar2(8000);begin  tsql := ' select ';   select (tsql || Subject || ',') into tsql from (select distinct Subject from cj) as cj;  tsql := substr(tsql,1,Length(tsql)-1);  tsql := tsql || ' from table3';  execute immediate tsql;end;
  相关解决方案