Bonjour,
à partir du code Java, j'essaie d'exécuter une procédure PL/SQL. mais j'obtiens une erreur alors que lorsque je l'exécute à partir de sqldevelopper, ma procédure fonctionne.

Voici ma procédure :
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
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
 
DECLARE
  lvl INT;
  nb INT;
BEGIN
  lvl := 0;
 
  INSERT INTO TABLE_HIERARCHIQUE (OPE_ID_FILS,OPE_ID_PERE,OPE_ID_LEVEL) (
    SELECT
      operation.ope_id,
      operation.ope_id_precedente,
      lvl
    FROM
     operation INNER JOIN type_operation
      ON operation.typ_top_id = type_operation.top_id
     LEFT OUTER JOIN apurement_incident_caisse
      ON operation.OPE_ID = apurement_incident_caisse.OPE_ID
     LEFT OUTER JOIN apurement_incident_atelier
      ON operation.OPE_ID = apurement_incident_atelier.OPE_ID
     LEFT OUTER JOIN incident_atelier_reception
      ON apurement_incident_atelier.OPE_ID_IAR = incident_atelier_reception.OPE_ID
     LEFT OUTER JOIN incident_caisse_reception
      ON apurement_incident_caisse.OPE_ID_ICR = incident_caisse_reception.OPE_ID
    WHERE
     operation.ope_date_operation > '01/01/2008'
     AND (operation.ope_num_operation <> operation.ope_code_regroupement
      OR ope_statut IN ('Annulé','Supprimé'))
     AND (TOP_IDENTIFIANT not in ('INCCAEXD','INCCAEXE','INCATBED','INCATBEE'))
     AND ((incident_caisse_reception.ICR_MT_RESTANT_APURER IS NULL AND incident_atelier_reception.IAR_MT_RESTANT_APURER IS NULL)
      OR incident_caisse_reception.ICR_MT_RESTANT_APURER = 0
      OR incident_atelier_reception.IAR_MT_RESTANT_APURER = 0
     )
    );
 
    LOOP
 
      INSERT INTO TABLE_HIERARCHIQUE (OPE_ID_FILS,OPE_ID_PERE,OPE_ID_LEVEL) (
        SELECT
          operation.ope_id,
          operation.ope_id_precedente,
          lvl+1
        FROM
          TABLE_HIERARCHIQUE INNER JOIN operation
            ON TABLE_HIERARCHIQUE.OPE_ID_PERE = operation.ope_id
            AND TABLE_HIERARCHIQUE.OPE_ID_LEVEL = lvl
      );
 
      nb := SQL%ROWCOUNT;
 
      IF nb = 0 THEN
        EXIT;
      END IF;
 
      lvl := lvl + 1;
 
    END LOOP;
   INSERT INTO EXTR_ID_ARC_PUR (EXTR_ID,OPE_ID,ID_FONC,SES_ID) (SELECT S_EXTR_ID_ARC_PUR.NEXTVAL,OPERATION.OPE_ID, OPERATION.OPE_NUM_OPERATION, 5000 FROM OPERATION INNER JOIN TABLE_HIERARCHIQUE ON OPERATION.OPE_ID = TABLE_HIERARCHIQUE.OPE_ID_FILS);
END;
Code Java :

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
 
/*déclaration en attribut dans ma classe, je l'instancie dans le constructeur*/
private TransactionnalQueryRunner txqueryRunner = null;
....
public void insertion() {
txqueryRunner.beginTransaction();
/* récupère l'url du fichier SQL qui contient la procédure PL/SQL ci dessus*/
String url = getRequest("requete.recherche.OPERATION.file");
/* je récupère la requête ci-dessus dans une chaine de caractère */
String requete = chargerSqlFichier(url);
debug ("fichier sql : " + requete);
CallableStatement cs = txqueryRunner.getDataSource().getConnection().prepareCall(requete);
cs.executeUpdate();
txqueryRunner.commitTransactionAndCloseQuietly();
}
J'obtiens cette erreur :
java.sql.SQLException: ORA-06550: line 1, column 8:
PLS-00103: Encountered the symbol "" when expecting one of the following:

begin function package pragma procedure subtype type use
<identificateur> <identificateur entre guillemets> form
current cursor
Vous savez d'où cela peut provenir ? alors que lorsque je l'exécute en SQL, ça fonctionne ....

Important : je ne peux pas créer de procédure stockée, (interdit chez le client), mais les procédure PL/SQL, autorisées

merci d'avance.