EXEMPLO_1212310
Database
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
ITENSPEDIDOEXAME
Parameters
Name
Type
Mode
@NUMEROPEDIDO
int
IN
Definition
/*LUIZ PHILIPE MOUTINHO VIEGAS - CP.2017.04_02 - OC.:MGCADBH-138 - 11/04/2017 VERSAO.: 12.1.17 - EQUIPE:MANUT */ CREATE PROCEDURE ITENSPEDIDOEXAME @NUMEROPEDIDO INTEGER AS DECLARE @CONT INTEGER DECLARE @MNEMONICO VARCHAR(50) DECLARE @CONCATENAMNEMONICO VARCHAR(255) DECLARE TABELA CURSOR FOR SELECT DISTINCT B.MNEMONICO FROM SZPEDEXAMEITEM A, SZLABEXAME B, SZUNIDATEND C WHERE A.ORDEMSERVICO = @NUMEROPEDIDO AND B.CODCOLIGADA = A.CODCOLIGADA AND B.CODEXAME = A.CODEXAME AND C.CODCOLIGADA = B.CODCOLIGADA AND C.IDUNIDATEND = B.IDUNIDATEND AND C.LABORATORIO = 'T' DELETE FROM SZITENSPEDEXAMEREL OPEN TABELA SET @CONT = 1 SET @CONCATENAMNEMONICO = '' FETCH NEXT FROM TABELA INTO @MNEMONICO WHILE (@@FETCH_STATUS=0) BEGIN SET @CONCATENAMNEMONICO = @CONCATENAMNEMONICO + @MNEMONICO + ' ' SET @CONT = @CONT+1 FETCH NEXT FROM TABELA INTO @MNEMONICO END INSERT INTO SZITENSPEDEXAMEREL (CONCATENA) VALUES( @CONCATENAMNEMONICO ) CLOSE TABELA DEALLOCATE TABELA