为什么此SELECT语句需要INTO子句

时间:2020-08-19 08:58:12

标签: oracle plsql

我有点困惑

FUNCTION IF_FORTNOX_EXIST(p_clientId IN INT)
   RETURN SYS_REFCURSOR IS 
    rc  SYS_REFCURSOR;
    BEGIN
    SELECT *    
    FROM fortnox_cron_job  WHERE ContentID = p_clientId AND ContentType = 'Client';
    RETURN rc;
END IF_FORTNOX_EXIST;

一旦我创建函数并对其进行编译,我就会报错并且不知道为什么? 以及如何使这些SELECT语句正常工作?

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

1 个答案:

答案 0 :(得分:2)

应该这样使用

FUNCTION IF_FORTNOX_EXIST(p_clientId IN INT)
   RETURN SYS_REFCURSOR 
AS 
    rc  SYS_REFCURSOR;

BEGIN

OPEN rc FOR 
  SELECT *    
  FROM fortnox_cron_job  
  WHERE ContentID = p_clientId 
  AND ContentType = 'Client';

  RETURN rc;
END IF_FORTNOX_EXIST;