从表和函数中选择
我有一个返回表的函数。返回的表包含(除其他外)一个 store_id。我可以获取特定 transaction_id 和 city_id 的 store_id,如下所示:
select store_id from table(user2.f_get_store(15, 12345));
--where 15 and 12345 are city_id and transation_id
我有另一个包含交易列表的表(其中包括 transaction_id 和 city_id)。 查询
store_id, city_id, transaction_id
我想要一个返回事务表中每个条目的 。我的第一个猜测是:(
select user2.f_get_store(city_id, transaction_id), city_id, transaction_id
from table_name;
简化了不重要的细节)
但是,这会产生“ORA-00932:不一致的数据类型”错误。我需要如何构建这个查询?
(我正在使用 Oracle)
~~~~~~编辑~~~~~~
当我尝试时
select user2.f_get_store(city_id, transactioN_id) from table_name;
,我收到权限不足的错误。我认为这是因为 f_get_store 的所有者与我正在使用的用户不同。
(我编辑了示例代码以显示该函数由不同用户拥有)
I have a function that returns a table. The returned table contains (among other things) a store_id. I can get the store_id for a particular transaction_id and city_id as follows:
select store_id from table(user2.f_get_store(15, 12345));
--where 15 and 12345 are city_id and transation_id
I have another table that contains a list of transactions (which includes transaction_id and city_id). I want a query that returns
store_id, city_id, transaction_id
for every entry in the transaction table. My first guess was:
select user2.f_get_store(city_id, transaction_id), city_id, transaction_id
from table_name;
(simplified away the unimportant details)
However, this yields an "ORA-00932: inconsistent datatypes" error. How do I need to structure this query?
(I'm using Oracle)
~~~~~EDIT~~~~~
When I try
select user2.f_get_store(city_id, transactioN_id) from table_name;
I get insufficient privileges error. I presume this is because f_get_store is owned by a different user than the one I am using.
(I edited the example code to show the function being owned by a different user)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你想要一个标量子查询:
I think you want a scalar subquery: