如何在oracle存储过程中使用多列进行选择

时间:2014-07-10 08:19:35

标签: oracle

CREATE OR REPLACE PROCEDURE get_pop1
AS
CUST_ID varchar2(100);
ROUTERNAME_N VARCHAR2(100);
BEGIN
SELECT TRAFFIC_CUST_ID INTO CUST_ID, ROUTERNAME INTO ROUTERNAME_N
FROM INTERFACE_ATTLAS
WHERE rownum < 2;
IF CUST_ID LIKE 'RNS%' THEN
dbms_output.put_line(CUST_ID);
dbms_output.put_line(ROUTERNAME_N);
ELSE
dbms_output.put_line('It doesn''t Contain');
END IF;
END;

/ *这里我试图获取多列并显示,但我收到以下错误:PROCEDURE GET_POP1的错误:

LINE/COL ERROR
-------- -----------------------------------------------------------------
6/3      PL/SQL: SQL Statement ignored
6/51     PL/SQL: ORA-00923: FROM keyword not found where expected
SQL> show errors  procedure get_pop1;
Errors for PROCEDURE GET_POP1:

LINE/COL ERROR
-------- -----------------------------------------------------------------
7/3      PL/SQL: SQL Statement ignored
7/51     PL/SQL: ORA-00923: FROM keyword not found where expected
16/3     PLS-00103: Encountered the symbol "IF"
SQL> show errors  procedure get_pop1;
Errors for PROCEDURE GET_POP1:

LINE/COL ERROR
-------- -----------------------------------------------------------------
6/3      PL/SQL: SQL Statement ignored
6/51     PL/SQL: ORA-00923: FROM keyword not found where expected
SQL> show errors  procedure get_pop1;
Errors for PROCEDURE GET_POP1:

LINE/COL ERROR
-------- -----------------------------------------------------------------
6/3      PL/SQL: SQL Statement ignored
6/51     PL/SQL: ORA-00923: FROM keyword not found where expected
SQL>

1 个答案:

答案 0 :(得分:0)

As documented in the manual into仅使用一次:

SELECT TRAFFIC_CUST_ID, ROUTERNAME
  into CUST_ID, ROUTERNAME_N
FROM INTERFACE_ATTLAS
WHERE rownum < 2;