简体   繁体   中英

How to use a user defined function in where clause in Oracle?

I want to do something like this:

SELECT subscription from TENANT where tenant_id = (select GET_TENANTID(12345) as tenant_id from DUAL);

Here, GET_TENANTID is a user-defined function. Also, tenant_id field is a varchar2 type column.

I'm on Oracle 12c.

Your code should work, but why not just do:

select subscription
from TENANT
where tenant_id = GET_TENANTID(12345);

One assumes that the types are the same. If they are not the same, convert the number to a string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM