createtable stuInfo ( stuID intprimarykey, stuName varchar2(20) ) createorreplaceprocedure proc1 is begin insertinto stuInfo values(1,'liheng'); end; createorreplaceprocedure proc2 ( v_ID int, v_Name varchar2 ) is begin insertinto stuInfo values(v_ID,v_Name); commit;---------记得要提交 end; createorreplaceprocedure proc3 ( v_ID int, v_Name out varchar2 ) is varName stuInfo.Stuname%type; begin select stuName into varName from stuInfo where stuID=v_ID; v_Name:=varName; end; =====================返回全部记录======================================= createorreplace package PKG_STUINFO is type stuInfoCursorType is ref cursor; procedure getStuInfo (stuInfoCursor out stuInfoCursorType); end; createorreplace package body PKG_STUINFO is procedure getStuInfo (stuInfoCursor out stuInfoCursorType) is var_cursor stuInfoCursorType; begin open var_cursor forselect*from stuInfo; stuInfoCursor:=var_cursor; end; end; =====================根据编号返回记录============================== createorreplace package PKG_STUINFO is type stuInfoCursorType is ref cursor; procedure getStuInfo (v_ID int,stuInfoCursor out stuInfoCursorType); end; createorreplace package body PKG_STUINFO is procedure getStuInfo (v_ID int,stuInfoCursor out stuInfoCursorType) is var_cursor stuInfoCursorType; begin if v_ID=0then open var_cursor forselect*from stuInfo; else open var_cursor forselect*from stuInfo where stuID=v_ID; endif; stuInfoCursor:=var_cursor; end; end; =========================根据姓名返回记录=========================== createorreplace package PKG_STUINFO is type stuInfoCursorType is ref cursor; procedure getStuInfo (v_Name varchar2,stuInfoCursor out stuInfoCursorType); end; createorreplace package body PKG_STUINFO is procedure getStuInfo (v_Name varchar2,stuInfoCursor out stuInfoCursorType) is var_cursor stuInfoCursorType; begin if v_Name =''then open var_cursor forselect*from stuInfo; else open var_cursor forselect*from stuInfo where stuName like'%'||v_Name||'%'; endif; stuInfoCursor:=var_cursor; end; end;