Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Didattica > Corsi A - F > Basi di dati ~ comunicazione digitale > Esame Perlasca
Pages (2): « 1 [2]   Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
Laertes
(lei'3tiz)

User info:
Registered: Sep 2004
Posts: 238 (0.03 al dì)
Location: Albignano D'Adda
Corso: ComDig!
Anno: Dottore!
Time Online: 2 Days, 13:06:38 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Mi sembra ovvio che essendoci l'esercizio sui trigger bisogna sapere PL/SQL quindi bisogna studiarsi tutto il pdf di MisterOracle su PL/SQL, quello protetto da password e con sfondo blu orribile per far si che non lo stampiamo... mannaggia a lui ho dovuto leggerlo tutto a computer...

Le domande di teoria, quando ho chiesto a Perlasca, non mi ha detto che sicuramente non ci saranno, era un "tendenzialmente no", ma era tutt'altro che sicuro...

Invece io ho un dubbio sull'esercizio di laboratorio, Perlasca sul sito ha scritto che sarà principalmente sulla parte di Php e dei Trigger, ora perchè mettere quel "principalmente" se PHP e Trigger sono praticamente TUTTO lab??!! visto che per saper fare i trigger bisogna sapere SQL e PL/SQL?? e soprattutto se l'esercizio è 1, come fa ad essere sia su php che sui trigger???... o è uno ma mastodontico... oppure nn so...

25-06-2006 18:07
Click Here to See the Profile for Laertes Click here to Send Laertes a Private Message Find more posts by Laertes Add Laertes to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
yeah
.grande:maestro.

User info:
Registered: Nov 2003
Posts: 1644 (0.20 al dì)
Location: Cologno Monzese
Corso: Informatica Magistrale
Anno: II
Time Online: 12 Days, 21:36:41 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

code:
IF(New.Smatr = Smatr) raise Exception("Già iscritto"); rollback;

Le altre porzioni sono giuste, su questa ho qualche dubbio: credo sia il trigger che mi ha messo in difficoltà all'esame.

Il problema è che il trigger si attiva e hai i valori in new, ma non ci sono riferimenti alle altre tuple della tabella (a meno che io mi sbagli). Ora lo scriverei così
code:
DECLARE res INTEGER; -- dovrà contenere 0 o 1 BEGIN SELECT 1 INTO res FROM Iscrizione WHERE Smatr=:new.Smatr; IF(res == 1) -- la matricola c'è già ROLLBACK; END IF; END.


Non sono sicuro della sintassi al 100%

In pratica se la query ha successo restituirà 1, altrimenti 0.
Il tutto si poteva scrivere anche così:

code:
DECLARE matr Iscrizione.Smatr%type; BEGIN SELECT Smatr INTO matr FROM Iscrizione WHERE Smatr=:new.Smatr; IF(matr != null) -- la matricola c'è già ROLLBACK; END IF; END.


Qui sono ancora più insicuro sulla sintassi, di certo questo modo è più complesso e se la query ritorna 2 matricole non penso funzioni (anche se si può considerare il fatto che Smatr è probabilmente chiave primaria -> necessariamente univoca)

__________________
?

26-06-2006 16:17
Click Here to See the Profile for yeah Click here to Send yeah a Private Message Find more posts by yeah Add yeah to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 23:06.    Post New Thread    Post A Reply
Pages (2): « 1 [2]   Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.075 seconds (51.61% PHP - 48.39% MySQL) con 24 query.