使用out参数选择存储过程的查询

时间:2022-06-25 16:35:19

I wrote Oracle stored procedure on oracle SQL developer with out parameters as below

我在oracle SQL开发人员上编写了Oracle存储过程,其参数如下所示

    create or replace PROCEDURE "SYSLOCKDAILY" 
    Is
     BEGIN


    select * from PDB2B_SYSTEMLOCKINFO 
           where ISDAILY = 1 
             and active = 1 
             and TO_TIMESTAMP (to_char(sysdate,'HH12:MI AM'),'HH12:MI AM') >=TO_TIMESTAMP (STIME,'HH12:MI AM') 
             and TO_TIMESTAMP (to_char(SYSDATE,'HH12:MI AM'),'HH12:MI AM') <= TO_TIMESTAMP (ETIME,'HH12:MI AM');



    COMMIT;
    END SYSLOCKDAILY;

But I got error as below on error log. Pls help me fix this.

但我在错误日志上得到如下错误。请帮我解决这个问题。

Error(9,2): PLS-00428: an INTO clause is expected in this SELECT statement

错误(9,2):PLS-00428:此SELECT语句中需要INTO子句

1 个解决方案

#1


2  

In PL/SQL columns of select statements must be assigned to variables using the INTO keyword. Try:

在PL / SQL中,必须使用INTO关键字将select语句的列分配给变量。尝试:

DECLARE
    v_number_of_rows int;
BEGIN
    SELECT COUNT(*) 
    INTO v_number_of_rows 
    FROM PDB2B_SYSTEMLOCKINFO 
    WHERE ...<your query>;
END;

In this example a single value will be stored in v_number_of_rows. If you need to handle multiple rows I recommend reading about Cursors.

在此示例中,单个值将存储在v_number_of_rows中。如果你需要处理多行,我建议阅读有关游标的内容。

#1


2  

In PL/SQL columns of select statements must be assigned to variables using the INTO keyword. Try:

在PL / SQL中,必须使用INTO关键字将select语句的列分配给变量。尝试:

DECLARE
    v_number_of_rows int;
BEGIN
    SELECT COUNT(*) 
    INTO v_number_of_rows 
    FROM PDB2B_SYSTEMLOCKINFO 
    WHERE ...<your query>;
END;

In this example a single value will be stored in v_number_of_rows. If you need to handle multiple rows I recommend reading about Cursors.

在此示例中,单个值将存储在v_number_of_rows中。如果你需要处理多行,我建议阅读有关游标的内容。