CORBASE | Bonsoir, je sollicite la communauté SQL / SERVER afin de m'aider sur un problème que je ne comprends pas. Cela fait bien 10h que je cherche l'erreur et je ne trouve pas.
J'effectue un curseur qui s'exécute deux fois, et la troisième fois, il ne veut plus ...
Voici le code :
Code :
- CREATE PROCEDURE CALCUL_INTEGRALE_VERTICALE
- @jaug_id int
- AS
- DECLARE @ord MES_COORD,
- @prof MES_COORD,
- @id int,
- @aire_totale float,
- @V_Temp MES_COORD,
- @Prof1 MES_COORD,
- @vitesse float
-
- -- // liste de verticales
- DECLARE C_verticale CURSOR
- FOR
- SELECT DISTINCT mes_abcisse
- FROM MESURE
- WHERE jaug_id = @jaug_id
- ORDER BY mes_abcisse
- -- // RAZ de la table firstintegrale
- DELETE FROM firstintegrale
-
- -- // Premier chargement
- OPEN C_verticale
- FETCH C_verticale INTO @ord
- WHILE @@fetch_Status = 0
- BEGIN
-
- SET @aire_totale = 0
- -- //création de la liste de chaque point de mesure pour une abcisse
- DECLARE C_point CURSOR
- FOR
- SELECT mes_id, mes_ordonnee, mes_vitesse
- FROM MESURE
- WHERE jaug_id = @jaug_id
- AND mes_abcisse = @ord
- ORDER BY mes_ordonnee
- BEGIN
- -- //premier chargement de points
- OPEN C_point
- FETCH C_point INTO @id, @prof, @vitesse
- SET @V_Temp = @vitesse
- SET @Prof1 = @prof
-
- WHILE @@fetch_Status = 0
- BEGIN
- FETCH C_point INTO @id, @prof, @vitesse
- SET @aire_totale = @aire_totale + (((@prof - @Prof1) * @V_Temp) + (((@prof - @Prof1) * (@vitesse - @V_Temp)) * 0.5)) * 0.01
-
- SET @V_Temp = @vitesse
- SET @Prof1 = @prof
- END
-
- -- //ajout de résultat
- INSERT INTO firstintegrale VALUES(@ord, @aire_totale)
-
- PRINT 'BOB ' + CONVERT(char, @ord)
- CLOSE C_point
- DEALLOCATE C_point
- -- // Prochaine abcisse
- FETCH C_verticale INTO @ord
- END
-
- CLOSE C_verticale
- DEALLOCATE C_verticale
- END
- GO
|
Voici l'erreur (extrait de Analyseur de requete) :
Code :
- (2 ligne(s) affectée(s))
- (1 ligne(s) affectée(s))
- BOB 18
- (1 ligne(s) affectée(s))
- BOB 38
- Serveur : Msg 16916, Niveau 16, État 1, Procédure CALCUL_INTEGRALE_VERTICALE, Ligne 73
- Un curseur nommé 'C_verticale' n'existe pas.
- Serveur : Msg 16916, Niveau 16, État 1, Procédure CALCUL_INTEGRALE_VERTICALE, Ligne 76
- Un curseur nommé 'C_verticale' n'existe pas.
- Serveur : Msg 16916, Niveau 16, État 1, Procédure CALCUL_INTEGRALE_VERTICALE, Ligne 77
- Un curseur nommé 'C_verticale' n'existe pas.
|
Le schéma de la table est :
Code :
- CREATE TABLE [MESURE] (
- [MES_ABCISSE] [MES_COORD] NULL ,
- [MES_ORDONNEE] [MES_COORD] NULL ,
- [MES_VALEUR] [numeric](18, 0) NULL ,
- [MES_TEMP_PRISE] [numeric](18, 0) NULL ,
- [MES_FOND] [bit] NULL ,
- [MES_ID] [int] IDENTITY (1, 1) NOT NULL ,
- [HEL_ID] [char] (7) COLLATE French_CI_AS NOT NULL ,
- [JAUG_ID] [int] NOT NULL ,
- [MES_VITESSE] [numeric](4, 1) NULL ,
- CONSTRAINT [PK_MESURE] PRIMARY KEY CLUSTERED
- (
- [MES_ID]
- ) ON [PRIMARY] ,
- CONSTRAINT [FK_MESURE_ETRE_PRIS_HELICE] FOREIGN KEY
- (
- [HEL_ID]
- ) REFERENCES [HELICE] (
- [HEL_ID]
- ),
- CONSTRAINT [FK_MESURE_JEAUGEAGE] FOREIGN KEY
- (
- [JAUG_ID]
- ) REFERENCES [JEAUGEAGE] (
- [JAUG_ID]
- )
- ) ON [PRIMARY]
- GO
|
Voici un petit DUMP de la table avec quelques données :
Code :
- 18,450,,100,,3,"1-15620",1,2.6
- 18,300,10,100,,4,"1-15620",1,2.6
- 18,150,10,100,,5,"1-15620",1,2.6
- 18,60,10,100,,6,"1-15620",1,2.6
- 18,10,10,100,,7,"1-15620",1,2.6
- 18,0,43,0,,8,"1-15620",1,.0
- 38,700,0,0,True,9,"1-15620",1,.0
- 38,680,46,100,,10,"1-15620",1,8.2
- 38,600,54,100,,11,"1-15620",1,8.4
- 38,400,86,100,,12,"1-15620",1,10.4
- 38,200,90,100,,13,"1-15620",1,11.1
- 38,60,102,100,,14,"1-15620",1,12.0
- 38,10,98,100,,15,"1-15620",1,11.4
- 38,0,0,0,,16,"1-15620",1,.0
- 45,600,10,100,,17,"1-15620",1,2.6
- 18,500,10,20,,37,"1-15620",1,2.6
- 18,500,10,20,,38,"1-15620",1,2.6
- 18,300,10,100,,39,"1-15620",1,2.6
- 45,200,10,20,,40,"1-15620",1,2.6
- 45,200,10,20,,41,"1-15620",1,2.6
- 45,150,10,20,,43,"1-15620",1,2.6
- 18,450,20,10,,50,"1-15620",1,5.2
- 18,450,,,,51,"1-15620",1,
- 18,450,,,,52,"1-15620",1,
- 18,450,,,,53,"1-15620",1,
- 18,450,,,,54,"1-15620",1,
|
Message édité par CORBASE le 16-05-2006 à 17:43:21
|