sql编写function
create or replace function gettypeidbyusername(username in varchar2) return varchar2 is
Result varchar2(4000);
type typeid_cur is ref cursor;
typeids typeid_cur;
begin
open typeids for select f.typeid
from funcinfo f,
functorole fr,
userinfo u,
usertorole ur
where f.id = fr.funcid
and fr.roleid = ur.roleid
and ur.userid = u.id
and u.loginname = username;
fetch typeids into Result;
close typeids;
return(Result);
end gettypeidbyusername;
入参就是userinfo表中的username,根据这个条件找到userid。根据这个userid到usertorole表中找到roleid。然后根据这个roleid到functorole表中找到funcid。然后根据这个funcid到funcinfo表中找到typeid的这个列表。返回
LZ你要干什么...
LZ服务大众,O(∩_∩)O~
呵呵
楼主好人啊~~~
需要用到函数和游标吗?
直接用sql语句就可以解决问题
^_^ 冒个泡
然后根据这个funcid到funcinfo表中找到typeid的这个列表。返回
返回多条记录的值,可以传出游标。实际上你的函数这么写的话已经不需要游标了。你写的是函数,可以将一组typeid拼成一个字符串。如果是10g以上的版本可以这么写
create or replace function gettypeidbyusername(username in
相关问答:
执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......
为了满足数据查询的速度问题,我将一张数据量大的学生表按年度分成多个表
students_2008, students_2009然后我又做了一个模板表students_template,模板表中的字段和students_2008, students_2009一样,只不过是一个 ......
pl/Sql如何查询字符串包括%,
例如:TABLE a
columnA
'222'
'33%44'
如何查询表a中columnA字段中哪些行包含'%'
谢谢
select * from a
where columna like '%/%%' escape '/'
UP
SELECT * from a ......
我要得到一个字符串如:
sdfk|||sgts
sdfsfd|||rgreg
wrfw|||sefw
就是要得到|||后面的字符串,有什么函数吗?怎么用呢?谢谢!
SQL code:
select
right(col,len(col)-charindex('|||',col)-2)
f ......
需求如下:
a表:
p_id status
1 0
2 0
b表
rec_id pid purchase_qty receive_qty flag
1 1 10 10 0
2 ......