<legend id='bfqre'><style id='bfqre'><dir id='bfqre'><q id='bfqre'></q></dir></style></legend>
        <tfoot id='bfqre'></tfoot>

        • <bdo id='bfqre'></bdo><ul id='bfqre'></ul>
      1. <small id='bfqre'></small><noframes id='bfqre'>

        <i id='bfqre'><tr id='bfqre'><dt id='bfqre'><q id='bfqre'><span id='bfqre'><b id='bfqre'><form id='bfqre'><ins id='bfqre'></ins><ul id='bfqre'></ul><sub id='bfqre'></sub></form><legend id='bfqre'></legend><bdo id='bfqre'><pre id='bfqre'><center id='bfqre'></center></pre></bdo></b><th id='bfqre'></th></span></q></dt></tr></i><div id='bfqre'><tfoot id='bfqre'></tfoot><dl id='bfqre'><fieldset id='bfqre'></fieldset></dl></div>
      2. PL/SQL 查询 IN 逗号分隔的字符串

        PL/SQL query IN comma deliminated string(PL/SQL 查询 IN 逗号分隔的字符串)

        <small id='0Z3qA'></small><noframes id='0Z3qA'>

        <tfoot id='0Z3qA'></tfoot>
        <i id='0Z3qA'><tr id='0Z3qA'><dt id='0Z3qA'><q id='0Z3qA'><span id='0Z3qA'><b id='0Z3qA'><form id='0Z3qA'><ins id='0Z3qA'></ins><ul id='0Z3qA'></ul><sub id='0Z3qA'></sub></form><legend id='0Z3qA'></legend><bdo id='0Z3qA'><pre id='0Z3qA'><center id='0Z3qA'></center></pre></bdo></b><th id='0Z3qA'></th></span></q></dt></tr></i><div id='0Z3qA'><tfoot id='0Z3qA'></tfoot><dl id='0Z3qA'><fieldset id='0Z3qA'></fieldset></dl></div>

        • <legend id='0Z3qA'><style id='0Z3qA'><dir id='0Z3qA'><q id='0Z3qA'></q></dir></style></legend>

            <bdo id='0Z3qA'></bdo><ul id='0Z3qA'></ul>

                <tbody id='0Z3qA'></tbody>
                • 本文介绍了PL/SQL 查询 IN 逗号分隔的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在 Oracle APEX 中开发应用程序.我有一个以逗号分隔的用户 ID 字符串,看起来像这样,

                  I am developing an application in Oracle APEX. I have a string with user id's that is comma deliminated which looks like this,

                  45,4932,20,19
                  

                  这个字符串存储为

                  :P5_USER_ID_LIST
                  

                  我想要一个查询来查找此列表中的所有用户,我的查询如下所示

                  I want a query that will find all users that are within this list my query looks like this

                  SELECT * FROM users u WHERE u.user_id IN (:P5_USER_ID_LIST);
                  

                  我不断收到 Oracle 错误:无效号码.但是,如果我将字符串硬编码到查询中,则它可以工作.像这样:

                  I keep getting an Oracle error: Invalid number. If I however hard code the string into the query it works. Like this:

                  SELECT * FROM users u WHERE u.user_id IN (45,4932,20,19);
                  

                  有人知道为什么这可能是一个问题吗?

                  Anyone know why this might be an issue?

                  推荐答案

                  绑定变量绑定 a 值,在本例中为字符串 '45,4932,20,19'.您可以按照 Randy 的建议使用动态 SQL 和串联,但您需要非常小心,用户无法修改此值,否则您会遇到 SQL 注入问题.

                  A bind variable binds a value, in this case the string '45,4932,20,19'. You could use dynamic SQL and concatenation as suggested by Randy, but you would need to be very careful that the user is not able to modify this value, otherwise you have a SQL Injection issue.

                  更安全的方法是将 ID 放入 PL/SQL 进程中的 Apex 集合中:

                  A safer route would be to put the IDs into an Apex collection in a PL/SQL process:

                  declare
                      array apex_application_global.vc_arr2;
                  begin
                      array := apex_util.string_to_table (:P5_USER_ID_LIST, ',');
                      apex_collection.create_or_truncate_collection ('P5_ID_COLL');
                      apex_collection.add_members ('P5_ID_COLL', array);
                  end;
                  

                  然后将您的查询更改为:

                  Then change your query to:

                  SELECT * FROM users u WHERE u.user_id IN 
                  (SELECT c001 FROM apex_collections
                   WHERE collection_name = 'P5_ID_COLL')
                  

                  这篇关于PL/SQL 查询 IN 逗号分隔的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to call Oracle function or stored procedure using spring persistence framework?(如何使用 Spring 持久化框架调用 Oracle 函数或存储过程?)
                  What can cause intermittent ORA-12519 (TNS: no appropriate handler found) errors(什么会导致间歇性 ORA-12519(TNS:找不到合适的处理程序)错误)
                  SQL to return the number of working days between 2 passed in dates(SQL 返回两个传入日期之间的工作日数)
                  Oracle Date Subtraction(Oracle 日期减法)
                  Is using quot;select *quot; for a cursor in PL/SQL considered bad programming?(正在使用“选择 *PL/SQL 中的游标被认为是糟糕的编程?)
                  Using sql/plsql, how do you find out which character set a text uses?(使用 sql/plsql,你如何找出文本使用的字符集?)
                    <bdo id='jY1fK'></bdo><ul id='jY1fK'></ul>

                      <small id='jY1fK'></small><noframes id='jY1fK'>

                      <tfoot id='jY1fK'></tfoot>
                        <tbody id='jY1fK'></tbody>

                          <legend id='jY1fK'><style id='jY1fK'><dir id='jY1fK'><q id='jY1fK'></q></dir></style></legend>
                          • <i id='jY1fK'><tr id='jY1fK'><dt id='jY1fK'><q id='jY1fK'><span id='jY1fK'><b id='jY1fK'><form id='jY1fK'><ins id='jY1fK'></ins><ul id='jY1fK'></ul><sub id='jY1fK'></sub></form><legend id='jY1fK'></legend><bdo id='jY1fK'><pre id='jY1fK'><center id='jY1fK'></center></pre></bdo></b><th id='jY1fK'></th></span></q></dt></tr></i><div id='jY1fK'><tfoot id='jY1fK'></tfoot><dl id='jY1fK'><fieldset id='jY1fK'></fieldset></dl></div>