以下是我用sql server写的函数,转到 oracle不适用了。
老是报:
Compilation errors for FUNCTION SL.F_GETCHILDError: PLS-00103: 出现符号 "@"在需要下列之一时:
<an identifier>
<a double-quoted delimited-identifier> current
Line: 1
Text: CREATE OR REPLACE Function F_getChild(@PID int)
这些错误。请有经验者不吝指教。
CREATE OR REPLACE Function F_getChild(@PID int)Return @tbTree table(FMID NUMBER,PMID NUMBER,FMNAME VARCHAR2(100),[LEVEL] INT)
as
begin
--临时表
declare @tbTemp table(FMID NUMBER,PMID NUMBER VARCHAR2(100),[LEVEL] INT)
insert into @tbTemp
select t.fmid,
t.pfmid,
lpad(' --',8*level-1)||t.fmname||' ' as FMNAME,
level
from SYS_FUNCTION t
start with t.pfmid=@PID
connect by nocycle prior t.fmid= t.pfmid
order by t.fmid,level declare @PidTemp int
set @PidTemp = @PID++
loop
while(@PidTemp<1000)
begin
if(!Exit(Select * from @tbTemp where FMID=@PidTemp))
begin
insert into @tbTemp
select t.fmid,
t.pfmid,
lpad(' --',8*level-1)||t.fmname||' ' as FMNAME,
level
from SYS_FUNCTION t
start with t.pfmid=@PidTemp
connect by nocycle prior t.fmid= t.pfmid
order by t.fmid,level
end
end
end loop
insert into @tbTree select * from @tbTemp
return
end
go
老是报:
Compilation errors for FUNCTION SL.F_GETCHILDError: PLS-00103: 出现符号 "@"在需要下列之一时:
<an identifier>
<a double-quoted delimited-identifier> current
Line: 1
Text: CREATE OR REPLACE Function F_getChild(@PID int)
这些错误。请有经验者不吝指教。
CREATE OR REPLACE Function F_getChild(@PID int)Return @tbTree table(FMID NUMBER,PMID NUMBER,FMNAME VARCHAR2(100),[LEVEL] INT)
as
begin
--临时表
declare @tbTemp table(FMID NUMBER,PMID NUMBER VARCHAR2(100),[LEVEL] INT)
insert into @tbTemp
select t.fmid,
t.pfmid,
lpad(' --',8*level-1)||t.fmname||' ' as FMNAME,
level
from SYS_FUNCTION t
start with t.pfmid=@PID
connect by nocycle prior t.fmid= t.pfmid
order by t.fmid,level declare @PidTemp int
set @PidTemp = @PID++
loop
while(@PidTemp<1000)
begin
if(!Exit(Select * from @tbTemp where FMID=@PidTemp))
begin
insert into @tbTemp
select t.fmid,
t.pfmid,
lpad(' --',8*level-1)||t.fmname||' ' as FMNAME,
level
from SYS_FUNCTION t
start with t.pfmid=@PidTemp
connect by nocycle prior t.fmid= t.pfmid
order by t.fmid,level
end
end
end loop
insert into @tbTree select * from @tbTemp
return
end
go
解决方案 »
- 新建的用户想要查询视图,应该赋予哪些权限
- PL/SQL中用select ...for update 会提示查询数据无法更新
- MS SQL语句如何转化为ORACLE语句
- sql取定量数据的问题,急急急,在线等结果请高手们指定
- 有没有办法 不真正执行语句,就知道大概需要多久,占用多少资源
- {SQL写法} 如何排序 字母 + 数字 混合的表?
- C#下读取 UDL文件连接Oracle数据库的问题,请各位高手赏光,急!!!!
- 有关建立表空间
- 有谁对Sql里面的union用法比较熟悉的,好好教教小弟如何?
- 求教oracle备份文件dmp导入数据库,头验证错误问题
- 怎么让月份按列显示?
- 疑难杂症:oracle SQL查询子节点并用树型显示子节点
临时表也不是那样用的。
变量赋值语句也不对。
sqlserver中用的是t-sql,而oracle中是pl/sql