PL/SQL

SQL>CREATE OR REPLACE PROCEDURE PrintMSG_Aaron(
p_sys_code IN test.SYS_CODE%TYPE) AS
   CURSOR c_msg IS
   SELECT MSG_CODE,SYS_CODE FROM test WHERE SYS_CODE=p_sys_code AND
   ROWNUM<10;
  
BEGIN
     FOR v_sys_recoder IN c_msg LOOP
       DBMS_OUTPUT.PUT_LINE(v_sys_recoder.MSG_CODE || ' ' || v_sys_recoder.SYS_CODE);
     END LOOP;
END;
/

SQL>set serveroutput on

SQL>BEGIN
   PrintMSG_Aaron('haha');
   END;
   /
SQL>.......

 

Table test:

Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 MSG_CODE                                  NOT NULL VARCHAR2(5)
 SYS_CODE                                  NOT NULL VARCHAR2(4)
 MSG_TYPE                                  NOT NULL VARCHAR2(1)
 MSG_DEST                                           VARCHAR2(3)
 MSG_DESC                                  NOT NULL VARCHAR2(60)

你可能感兴趣的:(sql,C++,c,C#)