Sybase 存儲過程的創建和執行
--返回值為int的存儲過程 create proc testReturn @tname varchar(12) , @tid int output as begin set @tid = (select testid from Mytest where testname=@tname) return end --返回值為varchar的存儲過程 create proc testReturnT @tid int , @tname varchar(12) output as begin set @tname = (select testname from Mytest where testid=@tid) return end --可以正確執行 declare @tid int exec testReturn 'testname', @tid output select @tid --本意是想直接輸出輸出參數 declare @tname varchar(12) exec @tname = testReturnT 3,@tname output select @tname --異常:Implicit conversion from datatype 'INT' to 'VARCHAR' is not allowed. Use the CONVERT function to run this query. --正確的執行方法 declare @tname varchar(12) declare @tid int exec @tid = testReturnT 3,@tname output select @tid select @tname --正確執行 declare @tname varchar(12) exec testReturnT 3,@tname output select @tname --注意:Sybase存儲過程執行之后 返回值的存儲過程成功與否的Int值
Oracle存儲過程的創建和執行
--創建 create PROCEDURE testReturn (tid in number , tname out NOCOPY varchar2 ) as begin select testname into tname from testtable where testid =tid; end testReturn;
SQL存儲過程的創建和執行
--創建 CREATE PROCEDURE procReturn @tid int , @tname varchar(12) output AS select @tname = testname from test1 where testid=@tid RETURN --執行 exec procReturn 2,@tname output