IN查询oracle的参数 [英] Parameter for IN query oracle

查看:186
本文介绍了IN查询oracle的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT * FROM EMPLOYEE
WHERE EMP_NAME IN (:EMP_NAME);

这是我的查询,现在我想将EMP_NAME参数作为字符串列表发送.
当我在SQL Developer中运行此查询时,要求发送EMP_NAME作为参数,现在我要发送"Kiran","Joshi"(基本上,我想获取员工名称为Kiran或Joshi的员工的详细信息.在执行查询期间如何传递值?

This is my query and now the EMP_NAME parameter I would like to send it as a list of strings.
When I run this query in SQL developer it is asked to send the EMP_NAME as a parameter, Now I want to send 'Kiran','Joshi' (Basically, I want to fetch the details of the employee with employee name either Kiran or Joshi. How should I pass the value during the execution of the query?

当我单独使用值Kiran时,它起作用,但是当我与任何其他字符串连接时,它将不起作用.有任何指针吗?

It works when I use the value Kiran alone, but when I concatenate with any other string it won't work. Any pointers in this?

我尝试了以下一个
'Kiran','Joshi'
上面的方式不起作用,因为这是一个参数,它将尝试使用名称为'Kiran',Joshi'的雇员,但不会出现.可以理解,但是为了实现这一目标,我该怎么做?

I tried the one below
'Kiran','Joshi'
The above way doesn't work as understood this is a single parameter it tries the employee with the name as 'Kiran',Joshi' which won't come. Understandable, but in order to achieve this thing, how can I go ahead?

任何帮助将不胜感激.

推荐答案

感谢帮助我解决此问题的人.

Thanks to the people who helped me in solving this problem.

我可以使用建议的方法来获得解决方案,以下是方法

I could get the solution using the way proposed, below is the approach

SELECT * FROM EMPLOYEE WHERE EMP_NAME IN (&EMP_NAME)

我已经尝试过这种方式,以下是我测试过的方案,它们可以正常工作.

I have tried in this way and following are the scenarios which I have tested and they are working fine.

场景1:

要仅获取"Kiran"的详细信息,则在这种情况下,当sql开发人员提示时,EMP_NAME的值将指定为Kiran.奏效了.

To fetch details of only "Kiran", then in this case the value of EMP_NAME when sql developer prompts is given as Kiran. It worked.

方案2:

要获取"Kiran""Joshi"的详细信息,则EMP_NAME的值将作为

To fetch details of either "Kiran" or "Joshi", then the value of EMP_NAME is sent as

Kiran','Joshi

在这种情况下它也起作用.

It worked in this case also.

感谢 Kedarnath 帮助我实现了解决方案:)

Thanks Kedarnath for helping me in achieving the solution :)

这篇关于IN查询oracle的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆