Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 conversion to tsql

Author  Topic 

zahid.sabreen
Starting Member

14 Posts

Posted - 2011-01-31 : 03:24:53
CREATE OR REPLACE PACKAGE GetEmpPckg IS

-- Strongly Typed REF CURSOR
-- A REF CURSOR that specifies a specific return type
TYPE emp_ref_cursor IS REF CURSOR RETURN emp%ROWTYPE;
--
-- Weakly Typed
-- A REF CURSOR that does not specify the return type such as SYS_REFCURSOR
-- TYPE emp_ref_cursor IS REF CURSOR;
PROCEDURE GetEmp
(p_dep IN emp.deptno%TYPE,
p_ref OUT emp_ref_cursor);
END GetEmpPckg;
/

Please help convert following code to t sql


CREATE OR REPLACE PACKAGE BODY GetEmpPckg IS
PROCEDURE GetEmp
(p_dep IN emp.deptno%TYPE,
p_ref OUT emp_ref_cursor) IS
BEGIN
OPEN p_ref FOR
SELECT empno, ename, job, mgr, hiredate, sal, comm, deptno
FROM emp
WHERE deptno = p_dep
ORDER BY ename;
END;
END GetEmpPckg;

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-02-01 : 05:08:16
SQL Server does not support package and ref cursor. You can simply use

create procedure GetEmp
(
@p_dep varchar(10)
)
as
SELECT empno, ename, job, mgr, hiredate, sal, comm, deptno
FROM emp
WHERE deptno = @p_dep
ORDER BY ename

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -