Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何将函数结果分配给SELECT的WITH子句中的名称?_Sql_Oracle_Select_Oracle19c_With Clause - Fatal编程技术网

Sql 如何将函数结果分配给SELECT的WITH子句中的名称?

Sql 如何将函数结果分配给SELECT的WITH子句中的名称?,sql,oracle,select,oracle19c,with-clause,Sql,Oracle,Select,Oracle19c,With Clause,如何将函数结果分配给WITH子句中的名称 尝试: 与 has_perm as(has_perm(:user)) 从my_表中选择*,其中的_perm='Y' 这就是你想要的吗 with has_perm as ( select has_perm(:user) as has_perm from dual ) select * from my_table where 'Y' = (select has_perm from has_perm); 为什么不在没有CTE

如何将函数结果分配给WITH子句中的名称

尝试:

与
has_perm as(has_perm(:user))
从my_表中选择*,其中的_perm='Y'
这就是你想要的吗

with has_perm as (
      select has_perm(:user) as has_perm
      from dual
     )
select *
from my_table
where 'Y' = (select has_perm from has_perm);
为什么不在没有CTE的情况下写呢

select *
from my_table
where has_perm(:user) = 'Y';

我不知道您所说的“在WITH子句中将函数结果分配给名称”是什么意思。你的意思是定义一个内联函数,例如,
with function has_perm(params)return number
,比如?是的,这就是我想要的,尽管有更好的语法来实现这一点。回答你的问题,因为在我的例子中,
有很多参数。