|  | Show 150 posts per page | 
.dsy:it. (http://www.dsy.it/forum/)
- Basi di dati ~ informatica triennale (http://www.dsy.it/forum/forumdisplay.php?forumid=211)
-- Domanda trigger (http://www.dsy.it/forum/showthread.php?threadid=43961)
Domanda trigger
CREATE OR REPLACE FUNCTION f1 RETURNS boolean AS $$
DECLARE
 
 r boolean;
 x1 correntista.max_prelievo%TYPE;
 x2 prelievo.prelievo TYPE;
 c1 CURSOR FOR SELECT prelievo FROM prelievo WHERE idcorrentista=$1;
Ciao a tutti, sottopongo alla vostra attenzione il seguente trigger. E' un quesito di un tema d'esame del 2004, al quale si deve scegliere la risposta corretta tra queste 4:
A) f1 restituisce error se il correntista $1 non è presente nella base dati.
B) f1 restituisce error se il correntista $1 non ha prelevato somme.
C) f1 restituisce true se il correntista $1 ha prelevato somme non superiori
    a max_prelievo.
D)f1 restituisce false se il correntista $1 non ha prelevato somme.
Vorrei sapere se anche secondo voi la risposta esatta è la D.
BEGIN
 SELECT max_prelievo INTO x1 FROM correntista WHERE correntista=$1;
  r=false;
  OPEN c1;
   LOOP
    FETCH c1 INTO x2;
    IF NOT FOUND THEN
      EXIT;
     END IF;
    IF x1>x2 THEN
      RETURN r;
    END IF;
   END LOOP;
  CLOSE c1;
  r=true;
  RETURN r;
END;
| All times are GMT. The time now is 15:43. | Show all 1 posts from this thread on one page | 
  Powered by: vBulletin Version 2.3.1
  Copyright © Jelsoft Enterprises Limited 2000 - 2002.