EXEMPLO_1212310
Database
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
FUNC_GETPARAM_TABLE
Parameters
Name
Type
Mode
@NOME_PARAMETRO
varchar
IN
Definition
CREATE FUNCTION FUNC_GETPARAM_TABLE (@NOME_PARAMETRO VARCHAR(MAX)) RETURNS @CURSOR_PARAMETRO TABLE ( COLIGADA INT, ID VARCHAR(MAX)) AS BEGIN DECLARE @COLIGADA INT DECLARE @VALOR_PARAMETRO VARCHAR(MAX) DECLARE @ID VARCHAR(MAX) DECLARE COLIGADAS CURSOR FOR SELECT HCPARAMETROS.CODCOLIGADA, HCPARAMETROS.VALORTEXT FROM HCPARAMETROS (NOLOCK) WHERE ( HCPARAMETROS.CODCOLIGADA <> 0 AND HCPARAMETROS.NOMECOLUNA = @NOME_PARAMETRO ) AND HCPARAMETROS.VALORTEXT IS NOT NULL OPEN COLIGADAS FETCH NEXT FROM COLIGADAS INTO @COLIGADA, @VALOR_PARAMETRO WHILE @@FETCH_STATUS = 0 BEGIN DECLARE CURSOR_PARAMETRO CURSOR FOR SELECT ITEM FROM SPLITSTRINGS(@VALOR_PARAMETRO, ';') OPEN CURSOR_PARAMETRO FETCH NEXT FROM CURSOR_PARAMETRO INTO @ID WHILE @@FETCH_STATUS = 0 BEGIN INSERT INTO @CURSOR_PARAMETRO SELECT @COLIGADA, @ID FETCH NEXT FROM CURSOR_PARAMETRO INTO @ID END CLOSE CURSOR_PARAMETRO DEALLOCATE CURSOR_PARAMETRO FETCH NEXT FROM COLIGADAS INTO @COLIGADA, @VALOR_PARAMETRO END CLOSE COLIGADAS DEALLOCATE COLIGADAS RETURN END