La fonction attend une valeur de type integer et renvoi les variables sous forme de table
USE [BORGER]
GO
/****** Object: UserDefinedFunction [dbo].[EXT_COORD_OFFRE] Script Date: 08/11/2017 22:05:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GOALTER FUNCTION [dbo].[EXT_COORD_OFFRE]
(
@PLVIDORG int
)RETURNS @COORD_OFFRE TABLE
(
PLVIDORG int,
ADRSOCIETE varchar(50),
ADRCONTACTTYPE varchar(50),
ADRCONTACTNOM varchar(50),
ADRCONTACTPRENOM varchar(30),
ADRL1 varchar(38),
ADRL2 varchar(38),
ADRL3 varchar(38),
ADRCODEPOSTAL varchar(9),
ADRVILLE varchar(35),
ADRPAYS varchar(50),
ADRTEL varchar(25),
ADRMAIL varchar(320)
)AS
BEGINdeclare @PCVIDORG int
declare @ADRIDORG intDeclare @ADRSOCIETE varchar(50)
Declare @ADRCONTACTTYPE varchar(50)
Declare @ADRCONTACTNOM varchar(50)
Declare @ADRCONTACTPRENOM varchar(30)
Declare @ADRL1 varchar(38)
Declare @ADRL2 varchar(38)
Declare @ADRL3 varchar(38)
Declare @ADRCODEPOSTAL varchar(9)
Declare @ADRVILLE varchar(35)
Declare @ADRPAYS varchar(50)
Declare @ADRTEL varchar(25)
Declare @ADRMAIL varchar(320)–insert into @COORD_OFFRE VALUES (null,null,null,null,null,null,null,null,null,null,null,null,null);
select @PCVIDORG = PCVID from [dbo].[PIECEVENTELIGNES]
where PLVID = @PLVIDORGSELECT @ADRIDORG = ADRID from [PIECEOFFRE]
where PCID = @PCVIDORGSELECT
@ADRSOCIETE = ADRSOCIETE,
@ADRCONTACTTYPE = ADRCONTACTTYPE,
@ADRCONTACTNOM = ADRCONTACTNOM,
@ADRCONTACTPRENOM = ADRCONTACTPRENOM,
@ADRL1 = ADRL1,
@ADRL2 = ADRL2,
@ADRL3 = ADRL3,
@ADRCODEPOSTAL = ADRCODEPOSTAL,
@ADRVILLE = ADRVILLE,
@ADRPAYS = ADRPAYS,
@ADRTEL = ADRTEL,
@ADRMAIL = ADRMAILfrom [ADRESSES]
WHERE ADRID = @ADRIDORGinsert into @COORD_OFFRE
SELECT
@PLVIDORG,
@ADRSOCIETE,
@ADRCONTACTTYPE,
@ADRCONTACTNOM,
@ADRCONTACTPRENOM,
@ADRL1,
@ADRL2,
@ADRL3,
@ADRCODEPOSTAL,
@ADRVILLE,
@ADRPAYS,
@ADRTEL,
@ADRMAILRETURN
END