Jusqu'à présent, j'utilisais sans problème la TStoredProc du BDE sous Delphi 6 (avec Oracle 10g).
Je commence à développer sous Delphi 2010, et je passe aux composants DBExpress.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 function ProduitEphemere(const szRacinePdt, szFinitPdt: String; Database: TDatabase): Integer; var StoredProc: TStoredProc; begin Result := 0; StoredProc := TStoredProc.Create(nil); try StoredProc.DatabaseName := Database.DatabaseName; StoredProc.StoredProcName := 'EST_UN_PRODUIT_EPHEMERE'; StoredProc.Params.CreateParam(ftString, 'pRACINE_PDT', ptInput); StoredProc.Params.CreateParam(ftString, 'pFINIT_PDT', ptInput); StoredProc.Params.CreateParam(ftFloat, 'Résultat', ptResult); try StoredProc.ParamByName('pRACINE_PDT').AsString := szRacinePdt; StoredProc.ParamByName('pFINIT_PDT').AsString := szFinitPdt; StoredProc.ExecProc; Result := StoredProc.ParamByName('Résultat').AsInteger; except on E: Exception do begin // Erreur ... Exit; end; end; finally StoredProc.Free; end; end;
Et là, j'ai une erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 function ProduitEphemere(const szRacinePdt, szFinitPdt: String; SQLConnection: TSQLConnection): Integer; var SQLStoredProc: TSQLStoredProc; begin Result := 0; SQLStoredProc := TSQLStoredProc.Create(nil); try SQLStoredProc.SQLConnection := SQLConnection; SQLStoredProc.StoredProcName := 'EST_UN_PRODUIT_EPHEMERE'; SQLStoredProc.Params.CreateParam(ftString, 'pRACINE_PDT', ptInput); SQLStoredProc.Params.CreateParam(ftString, 'pFINIT_PDT', ptInput); SQLStoredProc.Params.CreateParam(ftFMTBcd, 'Result', ptResult); try SQLStoredProc.ParamByName('pRACINE_PDT').AsString := szRacinePdt; SQLStoredProc.ParamByName('pFINIT_PDT').AsString := szFinitPdt; SQLStoredProc.ExecProc; Result := SQLStoredProc.ParamByName('Result').AsInteger; except on E: Exception do begin // Erreur ... Exit; end; end; finally SQLStoredProc.Free; end; end;J'ai donc ajouté SQLStoredProc.ParamCheck := False;, et j'obtiens une erreur PL/SQL. La fonction plante, car elle a reçu le contenu du deuxième paramètre dans le premier, et rien dans le deuxième."EST_UN_PRODUIT_EPHEMERE" : Le nombre réel de paramètres (4) a dépassé le nombre en cours de paramètres de procédure stockée (3). Désactivez la propriété de composant ParamCheck ou vérifiez le contenu de la liste de paramètres
Que faut-il faut faire pour créer convenablement ces paramètres ?
Partager