标签:
/*创建一个过程,ORACLE PL/SQL语法*/ CREATE OR REPLACE PROCEDURE MYPROC AS v_id t_user.id%TYPE; /*声明变量,类型与指定表字段一致*/ v_user t_user%ROWTYPE; /*声明变量,表示一行记录,结构与指定表一行记录一致*/ CURSOR c_user IS SELECT * FROM t_user; /*声明游标,表示多行记录,每一行结构与查询结果一致*/ BEGIN /*SELECT...INTO用法和%TYPE用法示例*/ SELECT MIN (id) INTO v_id FROM t_user; DBMS_OUTPUT.put_line (‘min(id) = ‘ || v_id); /*SELECT...INTO用法和%ROWTYPE用法示例*/ SELECT * INTO v_user FROM t_user; DBMS_OUTPUT.put_line (‘name = ‘ || v_user.username); /*FOR...IN...LOOP用法和CURSOR用法示例,temp结构和指定游标一行记录一致*/ FOR temp IN c_user LOOP DBMS_OUTPUT.put_line (‘name = ‘ || temp.username); END LOOP; END; /*调用过程,ORACLE PL/SQL语法*/ CALL MYPROC (); /*提交,ORACLE PL/SQL语法*/ COMMIT;
Oracle过程:%TYPE,%ROWTYPE,CURSOR,INTO,FOR...LOOP
标签:
原文地址:http://my.oschina.net/koulikoro/blog/405245