在PLSQL条件逻辑中使用子查询;错误PLS-00405 [英] Using a subquery within PLSQL conditional logic; error PLS-00405

查看:660
本文介绍了在PLSQL条件逻辑中使用子查询;错误PLS-00405的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个使用PHP从Oracle10g数据库服务器获取数据的应用程序.我的输入表单中有一系列复选框,这些复选框通过数组(过滤到相关元素的代码)提交给处理页面:

I am building an application that uses PHP to get data from an Oracle10g database server. My input form has a series of checkboxes that are submitted to the processing page via an array (code filtered down to the relevant elements):

<form>
   <input type="checkbox" name="p_queue_type[]" id="p_queue_type_CR" value="CR" class="subject_to_all toggle_subcategory required" required="">
   <input type="checkbox" name="p_queue_type[]" id="p_queue_type_HOLD" value="HOLD" class="subject_to_all toggle_subcategory required" required="">
</form>

处理页面调用一个Oracle过程,该过程使用自定义数据类型"STRING_TABLE"(CREATE OR REPLACE TYPE STRING_TABLE AS TABLE OF VARCHAR (1000);)将PHP数组处理的复选框值转换为表.

The processing page calls an Oracle procedure that uses a custom data type "STRING_TABLE" (CREATE OR REPLACE TYPE STRING_TABLE AS TABLE OF VARCHAR (1000);) to translate the checkbox values, which PHP processes as an array, into a table.

我的过程将这些复选框作为传入参数"p_queue_type"(代码过滤到相关元素):

My procedure takes those checkboxes as the incoming parameter "p_queue_type" (code filtered down to the relevant elements):

PROCEDURE get_TLFQ_results (
    p1                      OUT   SYS_REFCURSOR,
    p_queue_type            IN    STRING_TABLE
)
IS
    v_return_sql            VARCHAR2(32767) := '';
BEGIN
    IF ('HOLD' IN (SELECT COLUMN_VALUE AS queue_type FROM TABLE (p_queue_type))) THEN
        --compile query string
    END IF;
    IF ('CR' IN (SELECT COLUMN_VALUE AS queue_type FROM TABLE (p_queue_type))) THEN
        --compile query string
    END IF;

    -- Execute the query string and store the results in a cursor
    OPEN p1 FOR v_return_sql;
END get_TLFQ_results;

当我尝试编译过程时,出现此Oracle错误:

When I attempt to compile my procedure, I am getting this Oracle error:

[错误] PLS-00405(4215:23):PLS-00405:不允许在此子查询 上下文

[Error] PLS-00405 (4215: 23): PLS-00405: subquery not allowed in this context

我做错了什么?如何在PLSQL条件逻辑中使用字符串表?

What am I doing wrong? How can I use my string table within my PLSQL conditional logic?

推荐答案

您不能以这种方式在PL/SQL IF条件内使用SELECT语句.但是,您可以执行以下操作:

You cannot use a SELECT statement within a PL/SQL IF condition in that way. However you can do this:

IF ('HOLD'  member of p_queue_type) THEN
...

这篇关于在PLSQL条件逻辑中使用子查询;错误PLS-00405的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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