Précédent   Forum des professionnels en informatique > Bases de données > Firebird > SQL
SQL Forum d'entraide sur le SQL pour Firebird
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 22/02/2007, 10h10   #1
Membre du Club
 
Inscription : octobre 2004
Messages : 340
Détails du profil
Informations forums :
Inscription : octobre 2004
Messages : 340
Points : 53
Points : 53
Par défaut problemes avec procedures stockée

salut tout le monde ,pouvez vous m'aider cette procedure me donne des soucis :Multiple rows in singleton select
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
 
CREATE PROCEDURE BALCN (
    DEBUT DATE,
    FIN DATE)
RETURNS (
    COMPTE VARCHAR (10),
    INTT VARCHAR (80),
    ANVD NUMERIC (15, 2),
    ANVC NUMERIC (15, 2),
    ANV NUMERIC (15, 2),
    DEBIT NUMERIC (15, 2),
    CREDIT NUMERIC (15, 2),
    SOLDE NUMERIC (15, 2),
    SDEBIT NUMERIC (15, 2),
    SCREDIT NUMERIC (15, 2),
    SSOLDE NUMERIC (15, 2),
    FCLE INTEGER,
    CPT3 VARCHAR (3),
    CPT4 VARCHAR (4),
    CPT5 VARCHAR (5),
    CPT6 VARCHAR (6),
    CPT7 VARCHAR (7))
AS
Begin
FOR
SELECT 
  m.collectif,
  r.intitule,
  sum(m.debit) DEBIT_N,
  sum(m.credit) CREDIT_N,
  sum(m.debit)-sum(m.credit) TOTALN
FROM mouv  M
INNER JOIN compte r ON ( M.collectif=R.compte)
WHERE journal<>'ANV' AND JOURNAL<>'ANF' AND JOURNAL<>'ANC' AND M.datemvt BETWEEN :debut AND :fin
 
GROUP BY m.collectif,R.intitule,r.debit_n_1,R.credit_n_1
INTO :COMPTE, :INTT,:DEBIT , :CREDIT, :SOLDE
DO
Begin
ANVD=NULL;
ANVC=NULL;
IF ((substr(:compte,1,1)='6') OR (substr(:compte,1,1)='7')) then
begin
SELECT Debit, Credit FROM BALA WHERE compte=:Compte
INTO :ANVD,:ANVC;
end
else
begin
SELECT Debit, Credit FROM MOUV WHERE collectif=:Compte
AND JOURNAL='ANV'
 
INTO :ANVD,:ANVC;
end
 
IF (ANVD IS NULL) then ANVD=0;
IF (ANVC IS NULL) then ANVC=0;
ANV=:ANVD-:ANVC;
IF ((substr(:compte,1,1)=6) OR (substr(:compte,1,1)=7)) then
Begin
SDEBIT=:DEBIT;
SCREDIT=:CREDIT;
SSOLDE=:SOLDE;
end
else
begin
SDEBIT=:ANVD+:DEBIT;
SCREDIT=:ANVC+:CREDIT;
SSOLDE=:ANV+:SOLDE;
end
FCLE=1;
CPT3=SUBSTR(:COMPTE,1,3);
CPT4=SUBSTR(:COMPTE,1,4);
CPT5=SUBSTR(:COMPTE,1,5);
CPT6=SUBSTR(:COMPTE,1,6);
CPT7=SUBSTR(:COMPTE,1,7);
SUSPEND;
end
 
FOR
SELECT
  m.compte,
  r.intitule,
  m.debit,
  m.credit,
  m.debit-m.credit
FROM BALA  M
INNER JOIN compte r ON ( M.coMPTE=R.compte)
WHERE COMPTE NOT IN (SELECT DISTINCT COLLECTIF FROM MOUV WHERE JOURNAL<>'ANV' AND JOURNAL<>'ANF' AND JOURNAL<>'ANC' )
 
INTO :COMPTE, :INTT, :ANVD , :ANVC, :ANV
DO
Begin
DEBIT=0;
CREDIT=0;
SOLDE=0;
 
IF (substr(:compte,1,4)='1181') then
Begin
SELECT
  m.debit,
  m.credit,
  m.debit-m.credit
FROM mouv  M
INNER JOIN compte r ON ( M.coMPTE=R.compte)
WHERE JOURNAL='ANV' AND COMPTE=:COMPTE
INTO :ANVD , :ANVC, :ANV;
end
 
 
SDEBIT=:ANVD+:DEBIT;
SCREDIT=:ANVC+:CREDIT;
SSOLDE=:ANV+:SOLDE;
 
IF (substr(:compte,1,4)='1181') then
Begin
SELECT
  m.debit,
  m.credit,
  m.debit-m.credit
FROM BALA  M
INNER JOIN compte r ON ( M.coMPTE=R.compte)
WHERE COMPTE=:COMPTE
INTO :ANVD , :ANVC, :ANV;
end
FCLE=0;
CPT3=SUBSTR(:COMPTE,1,3);
CPT4=SUBSTR(:COMPTE,1,4);
CPT5=SUBSTR(:COMPTE,1,5);
CPT6=SUBSTR(:COMPTE,1,6);
CPT7=SUBSTR(:COMPTE,1,7);
SUSPEND;
end
end
Merci
nah_wah est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/02/2007, 10h18   #2
Modérateur
 
Avatar de Cl@udius
 
Homme Claude Renouleaud
Développeur informatique
Inscription : février 2006
Messages : 4 758
Détails du profil
Informations personnelles :
Nom : Homme Claude Renouleaud
Âge : 49
Localisation : France, Hautes Pyrénées (Midi Pyrénées)

Informations professionnelles :
Activité : Développeur informatique

Informations forums :
Inscription : février 2006
Messages : 4 758
Points : 6 779
Points : 6 779
Salut

Je n'ai pas examiné ta PS en détail, mais le message d'erreur 'Multiple rows in singleton select' signifie simplement qu'un select renvoie plusieurs enregistrements alors qu'il est sensé n'en recevoir qu'un.

Si cela peut t'aider à debugger ta PS...

@+ Claudius
__________________
A la question technique que par MP/MV tu formuleras, la réponse aux oubliettes finira.
Cl@udius est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/02/2007, 10h28   #3
Membre du Club
 
Inscription : octobre 2004
Messages : 340
Détails du profil
Informations forums :
Inscription : octobre 2004
Messages : 340
Points : 53
Points : 53
oui effectivement mais je ne sais le quel puisque tout mes autres bases de données marche tres bien pouvez vous l'examiner svp
nah_wah est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 22/02/2007, 12h15   #4
Nouveau Membre du Club
 
Inscription : juin 2006
Messages : 45
Détails du profil
Informations forums :
Inscription : juin 2006
Messages : 45
Points : 35
Points : 35
A mon avis c'est celle-ci :
Code :
1
2
3
4
5
6
7
8
9
10
 
SELECT
m.collectif,
r.intitule,
sum(m.debit) DEBIT_N,
sum(m.credit) CREDIT_N,
sum(m.debit)-sum(m.credit) TOTALN
FROM mouv M
INNER JOIN compte r ON ( M.collectif=R.compte)
WHERE journal<>'ANV' AND JOURNAL<>'ANF' AND JOURNAL<>'ANC' AND M.datemvt BETWEEN :debut AND :fin
Tu as plusieurs "collectif" et "intitule" mais les "SUM" sont uniques
amnir est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 18h09.


 
 
 
 
Partenaires

Hébergement Web