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

时间:2018-04-02 04:50:55

标签: sql oracle stored-procedures plsql

我在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;

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

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

1 个答案:

答案 0 :(得分:2)

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

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

在此示例中,单个值将存储在v_number_of_rows中。如果您需要处理多行,我建议您阅读Cursors