USE [chss_back]
GO
/****** 對象: StoredProcedure [dbo].[sp_Public_PyWbmGet] 腳本日期: 07/28/2015 10:54:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE procedure [dbo].[sp_Public_PyWbmGet]
@tablename varchar(32),
@fieldname1 varchar(32),
@fieldname2 varchar(32),
@pybz char(1) = '0'
as
set nocount on
exec('declare @name varchar(255),@shortcut varchar(255)'+
' declare cs_py cursor for select '+@fieldname1+','+@fieldname2+
' from '+@tablename+
' where '+@fieldname2+ ' is null'+
' for update of '+@fieldname2+
' open cs_py'+
' fetch cs_py into @name,@shortcut'+
' while @@fetch_status=0'+
' begin exec sp_Public_PyWbm @name,'+@pybz+',@shortcut output'+
' update '+@tablename+' set '+@fieldname2+'=convert(varchar(40),@shortcut)'+
' where current of cs_py'+
' fetch cs_py into @name,@shortcut end'+
' close cs_py deallocate cs_py'
)
GO
上面太亂了
1. declare
2. type empdtlrec is record (empno number(4),
3. ename varchar2(20),
4. deptno number(2));
5. empdtl empdtlrec;
6. begin
7. execute immediate ‘select empno, ename, deptno ’ ||
8. ‘from emp where empno = 7934’
9. into empdtl;
10. end;
可參考
http://blog.csdn.net/xiooix2012/article/details/6895594