Top Banner
Select A.ID_Caballo from Caballo_Carrera A, Caballo_Jinete B where a.ID_Caballo =B.ID_Caballo AND Resultado=1 Select ID_Caballo from Caballo_Jinete ----Sacar la lista de los Caballos y los Jinetes(nombre del Caballo, nombre del jinete, ----así como la carrera (id_carrera) de aquellos caballos que no han obtenido el primer lugar --If OBJECT_ID('Noprimer','P') IS NOT NULL --DROP PROCEDURE Noprimer Create Procedure Cab_Jin_Carr_NoprimerDDD @IDJ numeric(6) As Begin Declare @CARRERAC Cursor Set @CARRERAC = Cursor For Select ID_Caballo from Caballo_Jinete Open @CARRERAC Fetch next from @CARRERAC into @IDJ While @@FETCH_STATUS=0 Begin If(Select ID_Caballo from Caballo_Carrera where ID_Caballo =@IDJ AND Resultado=1) IS NULL Select A.ID_Jinete, B.ID_Caballo, C.ID_Carrera From Jinetes A, Caballo_Jinete B, Caballo_Carrera C Where B.ID_Caballo=@IDJ AND A.ID_Jinete = B.ID_Jinete Fetch Next from @CARRERAC into @IDJ End Close @CARRERAC Deallocate @CARRERAC End
6

3tres tristes tigres

Dec 21, 2015

Download

Documents

Daaha2

tercer archivo
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 3tres tristes tigres

Select A.ID_Caballo from Caballo_Carrera A, Caballo_Jinete B where a.ID_Caballo =B.ID_Caballo AND Resultado=1

Select ID_Caballo from Caballo_Jinete

----Sacar la lista de los Caballos y los Jinetes(nombre del Caballo, nombre del jinete, ----así como la carrera (id_carrera) de aquellos caballos que no han obtenido el primer lugar

--If OBJECT_ID('Noprimer','P') IS NOT NULL--DROP PROCEDURE Noprimer

Create Procedure Cab_Jin_Carr_NoprimerDDD

@IDJ numeric(6)As Begin

Declare @CARRERAC Cursor Set @CARRERAC = Cursor For Select ID_Caballo from Caballo_Jinete Open @CARRERAC

Fetch next from @CARRERAC into @IDJWhile @@FETCH_STATUS=0

BeginIf(Select ID_Caballo from Caballo_Carrera where ID_Caballo =@IDJ AND Resultado=1) IS NULLSelect A.ID_Jinete, B.ID_Caballo, C.ID_Carrera From Jinetes A, Caballo_Jinete B, Caballo_Carrera C Where B.ID_Caballo=@IDJ AND

A.ID_Jinete = B.ID_Jinete

Fetch Next from @CARRERAC into @IDJEndClose @CARRERACDeallocate @CARRERAC

End

Page 2: 3tres tristes tigres
Page 3: 3tres tristes tigres

SÓLO CABALLOS

----Sacar la lista de los Caballos y los Jinetes(nombre del Caballo, nombre del jinete, ----así como la carrera (id_carrera) de aquellos caballos que no han obtenido el primer lugar

--If OBJECT_ID('Noprimer','P') IS NOT NULL--DROP PROCEDURE Noprimer

Create Procedure JineteNoprimerPPP

@IDJ numeric(6)AsBegin

Declare @CARRERAC Cursor Set @CARRERAC = Cursor For Select ID_Caballo from Caballo_Jinete Open @CARRERAC

Fetch next from @CARRERAC into @IDJWhile @@FETCH_STATUS=0

BeginIf(Select ID_Caballo from Caballo_Carrera where ID_Caballo =@IDJ AND Resultado=1) IS NULLSelect * From Caballos Where ID_Caballo=@IDJ--Select A.* From Jinetes A, Caballo_Jinete B Where B.ID_Caballo=@IDJ AND A.ID_Jinete = B.ID_Jinete

Fetch Next from @CARRERAC into @IDJEndClose @CARRERACDeallocate @CARRERAC

End

Page 4: 3tres tristes tigres

SÓLO JINETES----Sacar la lista de los Caballos y los Jinetes(nombre del Caballo, nombre del jinete, ----así como la carrera (id_carrera) de aquellos caballos que no han obtenido el primer lugar

--If OBJECT_ID('Noprimer','P') IS NOT NULL--DROP PROCEDURE Noprimer

Create Procedure JineteNoprimerQQQ

@IDJ numeric(6)AsBegin

Declare @CARRERAC Cursor Set @CARRERAC = Cursor For Select ID_Caballo from Caballo_Jinete Open @CARRERAC

Fetch next from @CARRERAC into @IDJWhile @@FETCH_STATUS=0

BeginIf(Select ID_Caballo from Caballo_Carrera where ID_Caballo =@IDJ AND Resultado=1) IS NULL--Select * From Caballos Where ID_Caballo=@IDJSelect A.* From Jinetes A, Caballo_Jinete B Where B.ID_Caballo=@IDJ AND A.ID_Jinete = B.ID_Jinete

Fetch Next from @CARRERAC into @IDJEndClose @CARRERACDeallocate @CARRERAC

End

Page 5: 3tres tristes tigres

JINETES Y CABALLOS----Sacar la lista de los Caballos y los Jinetes(nombre del Caballo, nombre del jinete, ----así como la carrera (id_carrera) de aquellos caballos que no han obtenido el primer lugar

--If OBJECT_ID('Noprimer','P') IS NOT NULL--DROP PROCEDURE Noprimer

Create Procedure JineteNoprimerBBB

@IDJ numeric(6)AsBegin

Declare @CARRERAC Cursor Set @CARRERAC = Cursor For Select ID_Caballo from Caballo_Jinete Open @CARRERAC

Fetch next from @CARRERAC into @IDJWhile @@FETCH_STATUS=0

BeginIf(Select ID_Caballo from Caballo_Carrera where ID_Caballo =@IDJ AND Resultado=1) IS NULLSelect A.*, C.* From Jinetes A, Caballo_Jinete B, Caballos C Where B.ID_Caballo=@IDJ AND A.ID_Jinete = B.ID_Jinete AND

B.ID_Caballo = C.ID_Caballo--Select * From Caballos Where ID_Caballo=@IDJ--Select A.* From Jinetes A, Caballo_Jinete B Where B.ID_Caballo=@IDJ AND A.ID_Jinete = B.ID_Jinete--XXXXXXXXXSelect A.* From Jinetes A, Caballo_Jinete B Where B.ID_Caballo=@IDJ

Fetch Next from @CARRERAC into @IDJEndClose @CARRERACDeallocate @CARRERAC

End

Page 6: 3tres tristes tigres

NO EJECUTA NADA, SOLO MUESTRA DENTRO DEL IF LAS POSIBLES SOLUCIONES DE CABALLO, JINETE Y ID JUNTOS

----Sacar la lista de los Caballos y los Jinetes(nombre del Caballo, nombre del jinete, ----así como la carrera (id_carrera) de aquellos caballos que no han obtenido el primer lugar

--If OBJECT_ID('Noprimer','P') IS NOT NULL--DROP PROCEDURE Noprimer

Create Procedure JineteNoprimerDDD

@IDJ numeric(6)AsBegin

Declare @CARRERAC Cursor Set @CARRERAC = Cursor For Select ID_Caballo from Caballo_Jinete Open @CARRERAC

Fetch next from @CARRERAC into @IDJWhile @@FETCH_STATUS=0

BeginIf(Select ID_Caballo from Caballo_Carrera where ID_Caballo =@IDJ AND Resultado=1) IS NULLSelect A.*, C.*, D.ID_Carrera From Jinetes A, Caballo_Jinete B, Caballos C, Caballo_Carrera D Where B.ID_Caballo=@IDJ AND

A.ID_Jinete = B.ID_Jinete AND B.ID_Caballo = C.ID_Caballo AND D.ID_Caballo = C.ID_Caballo --Select * From Caballos Where ID_Caballo=@IDJ--Select A.* From Jinetes A, Caballo_Jinete B Where B.ID_Caballo=@IDJ AND A.ID_Jinete = B.ID_Jinete--XXXXXXXXXSelect A.* From Jinetes A, Caballo_Jinete B Where B.ID_Caballo=@IDJ

Fetch Next from @CARRERAC into @IDJEndClose @CARRERACDeallocate @CARRERAC

End