Sample Header Ad - 728x90

syntax error at or near TO (ROLLBACK TO SAVEPOINT)

0 votes
1 answer
1535 views
The following sql is a part from a FUNCTION ,i want to rollback to rbk SAVEPOINT :
for ptrEnt in entite loop
      -- positionnement du point de retour pour une entité
    savepoint rbk;
      -- purge de la table des redevances de l''entite
    test := pckg_activ.initredevanceentite(ptrEnt.cod_ent);
      -- calcul de la redevance
      test := pckg_activ.calculredevanceentite(ptrEnt.cod_ent);
    -- controle calcul de la bonne execution pour l''entité
    if (test = 0) then
        -- initialisation des departements associes a une entite
        test := pckg_activ.initdepartement(ptrEnt.cod_ent);
      -- validation des modifications
      commit;
      -- generation de l''etat recapitulatif
      test := pckg_activ.recapentitegestionnaire(ptrEnt.cod_ent,ficHisto);
    else
        rollback TO SAVEPOINT rbk;
      report := jour + 7;
      update sav_rdv_date
          set date_dem = report
          where cod_ent = ptrEnt.cod_ent;
        RAISE NOTICE '!!erreur de patrimoine => abandon du traitement pour cette entite';
      commit;
    end if;
  end loop;
**entite** is a cursor that has been declared and the **for loop** is in a *BEGIN* bloc. I get the error ERROR:
error at or near "TO"
. I think that the syntax is correct , it it related to the cursor ?
Asked by unknownUser (29 rep)
Apr 22, 2020, 03:58 PM
Last activity: Aug 15, 2021, 02:12 PM