La funcion no compila

05/09/2006 - 19:18 por Silviall | Informe spam
Hola a todos,

Tengo esta funcion que no me compila alguien me puede decir porqué?
IF OBJECT_ID (N'dbo.MonitorsPossibles', N'FN') IS NOT NULL

DROP FUNCTION dbo.MonitorsPossibles;

GO

CREATE FUNCTION dbo.MonitorsPossibles(@DATAINI datetime,@DATAFI datetime)

RETURNS @taula TABLE

(

codipersonal INT

)

AS

BEGIN

if (datepart(dw,@DATAINI)=2)

begin

insert into @taula

select * from MonitorsDilluns (@dataini,@datafi)

end

else

begin

insert into @taula

select * from MonitorsDimarts (@dataini,@datafi)

end

END

GO

ERROR: The last statement included within a function must be a return
statement.



SilviaLl.

Preguntas similare

Leer las respuestas

#1 Alejandro Mesa
05/09/2006 - 19:46 | Informe spam
Silviall,

Ya chequeastes las respuestas que dieron en tu primer posting?

http://support.microsoft.com/newsgr...sloc=en-US

Si deseas usar alguna instruccion de control de flujo en tu funcion,
entonces esta debe usar la estructura de una funcion tipo tabla multi
sentencias. No puedes usar "retuns table", si no que debes especificar la
estructura de la tabla que devuelve.


AMB


"Silviall" wrote:

Hola a todos,

Tengo esta funcion que no me compila alguien me puede decir porqué?
IF OBJECT_ID (N'dbo.MonitorsPossibles', N'FN') IS NOT NULL

DROP FUNCTION dbo.MonitorsPossibles;

GO

CREATE FUNCTION dbo.MonitorsPossibles(@DATAINI datetime,@DATAFI datetime)

RETURNS @taula TABLE

(

codipersonal INT

)

AS

BEGIN

if (datepart(dw,@DATAINI)=2)

begin

insert into @taula

select * from MonitorsDilluns (@dataini,@datafi)

end

else

begin

insert into @taula

select * from MonitorsDimarts (@dataini,@datafi)

end

END

GO

ERROR: The last statement included within a function must be a return
statement.



SilviaLl.



Respuesta Responder a este mensaje
#2 Silviall
05/09/2006 - 20:45 | Informe spam
Esta función es como la que me mandaron en el primer posting, pero no me
funciona y queria saber como lo puedo hacer?


"Alejandro Mesa" escribió en el
mensaje news:
Silviall,

Ya chequeastes las respuestas que dieron en tu primer posting?

http://support.microsoft.com/newsgr...sloc=en-US

Si deseas usar alguna instruccion de control de flujo en tu funcion,
entonces esta debe usar la estructura de una funcion tipo tabla multi
sentencias. No puedes usar "retuns table", si no que debes especificar la
estructura de la tabla que devuelve.


AMB


"Silviall" wrote:

Hola a todos,

Tengo esta funcion que no me compila alguien me puede decir porqué?
IF OBJECT_ID (N'dbo.MonitorsPossibles', N'FN') IS NOT NULL

DROP FUNCTION dbo.MonitorsPossibles;

GO

CREATE FUNCTION dbo.MonitorsPossibles(@DATAINI datetime,@DATAFI datetime)

RETURNS @taula TABLE

(

codipersonal INT

)

AS

BEGIN

if (datepart(dw,@DATAINI)=2)

begin

insert into @taula

select * from MonitorsDilluns (@dataini,@datafi)

end

else

begin

insert into @taula

select * from MonitorsDimarts (@dataini,@datafi)

end

END

GO

ERROR: The last statement included within a function must be a return
statement.



SilviaLl.



Respuesta Responder a este mensaje
#3 Silviall
05/09/2006 - 20:54 | Informe spam
Ya he solucionado el problema es solo poner un return al final.

"Silviall" <slladoARROBAgmailPUNTOcoEME> escribió en el mensaje
news:%23E$
Esta función es como la que me mandaron en el primer posting, pero no me
funciona y queria saber como lo puedo hacer?


"Alejandro Mesa" escribió en el
mensaje news:
Silviall,

Ya chequeastes las respuestas que dieron en tu primer posting?

http://support.microsoft.com/newsgr...sloc=en-US

Si deseas usar alguna instruccion de control de flujo en tu funcion,
entonces esta debe usar la estructura de una funcion tipo tabla multi
sentencias. No puedes usar "retuns table", si no que debes especificar la
estructura de la tabla que devuelve.


AMB


"Silviall" wrote:

Hola a todos,

Tengo esta funcion que no me compila alguien me puede decir porqué?
IF OBJECT_ID (N'dbo.MonitorsPossibles', N'FN') IS NOT NULL

DROP FUNCTION dbo.MonitorsPossibles;

GO

CREATE FUNCTION dbo.MonitorsPossibles(@DATAINI datetime,@DATAFI
datetime)

RETURNS @taula TABLE

(

codipersonal INT

)

AS

BEGIN

if (datepart(dw,@DATAINI)=2)

begin

insert into @taula

select * from MonitorsDilluns (@dataini,@datafi)

end

else

begin

insert into @taula

select * from MonitorsDimarts (@dataini,@datafi)

end

END

GO

ERROR: The last statement included within a function must be a return
statement.



SilviaLl.









email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida