IF EXISTS (SELECT * FROM SYSOBJECTS O, SYSUSERS U
                    WHERE
	        O.NAME = 'CURSOR_PRODLOCAL' AND
	        TYPE = 'P'                    AND
	        U.UID = O.UID                 AND
	        U.NAME = USER)

   DROP PROCEDURE CURSOR_PRODLOCAL
   GO

CREATE PROCEDURE CURSOR_PRODLOCAL
  @P_CDFILIAL      VARCHAR(4),
  @P_CDPRODUTO     VARCHAR(10),
  @P_CURSOR_LOC   CURSOR VARYING OUTPUT

AS
  SET @P_CURSOR_LOC = CURSOR FORWARD_ONLY STATIC FOR
     SELECT CDSUBPRODLOC
     FROM ROTFABLOCAL
     WHERE CDFILIAL  = @P_CDFILIAL AND
           CDPRODUTO = @P_CDPRODUTO;
     OPEN @P_CURSOR_LOC
GO

