Subject | Re: [ib-support] Re: Exception handling |
---|---|
Author | Marco Bommeljé |
Post date | 2002-11-21T14:59:28Z |
Hi all,
Yes you can have triggers on views. It's one of the big Ib/Fb
advantages. You can make views updatable even when SQL standard says
they aren't.
Try this on the employee.gdb's phone_list view:
close to the data as possible, i.e. on base tables. Preferrably in
declarative constraints, or otherwise in triggers.
Good luck,
Marco
Svein Erling Tysvaer wrote:
Yes you can have triggers on views. It's one of the big Ib/Fb
advantages. You can make views updatable even when SQL standard says
they aren't.
Try this on the employee.gdb's phone_list view:
> set term ^;However, in the case of your application, you should check validity as
> create trigger phone_list_bu for phone_list before update
> as
> begin
> /* employee base table */
> update employee set phone_ext = new.phone_ext
> where emp_no = new.emp_no ;
> /* department base table */
> update department set location = new.location , phone_no = new.phone_no
> where dept_no = (select dept_no from employee where emp_no = new.emp_no);
> end
> ^
> set term ;^
close to the data as possible, i.e. on base tables. Preferrably in
declarative constraints, or otherwise in triggers.
Good luck,
Marco
Svein Erling Tysvaer wrote:
> No, you cannot have triggers on views, I thought you were going to use it
> so that it was impossible to overbook a hotel or something and then I
> thought it would be better to prevent that from happening by using a
> trigger (or check constraint) on the actual column that shouted NEJ when
> you tried to book a room that wasn't available.
>
> As for your view, I'm only curious as to why you use the old SQL-89
> notation. In general SQL-92 is recommended, i.e.
>
> CREATE VIEW VY_SANGPLATSER AS
> select V.PLATSID, P.PERSNR, P.FNAMN, P.ENAMN, V.SANGNR, V.RUMNR,
> A.AVDID, A.NAMN, P.KON, I.INSKRIVID, INTAG.INTAGID
> from TBLINSKRIVNING I
> join TBLINTAGNING INTAG on I.INSKRIVID = INTAG.INSKRIVID
> join TBLVARDPLATS V on V.PLATSID = INTAG.PLATSID
> join TBLAVDELNING A on A.AVDID = INTAG.AVDID
> join TBLPATIENT P on P.PERSNR = I.PERSNR
> ;
>
> (Easier to read and e.g. makes JoinLinks in IBO redundant)
> Set
>
> At 13:30 21.11.2002 +0000, you wrote:
> >Could this be acomplished witha a insert/uppdate trigger on this
> >following view where count is to be controlled on P.PERSNR is not
> >larger then 20:
> >
> >CREATE VIEW VY_SANGPLATSER AS
> >select V.PLATSID, P.PERSNR, P.FNAMN, P.ENAMN, V.SANGNR, V.RUMNR,
> >A.AVDID, A.NAMN, P.KON, I.INSKRIVID, INTAG.INTAGID
> >from TBLVARDPLATS V, TBLAVDELNING A, TBLPATIENT P, TBLINSKRIVNING I,
> >TBLINTAGNING INTAG
> >WHERE P.PERSNR = I.PERSNR
> >AND
> >V.PLATSID = INTAG.PLATSID
> >AND
> >A.AVDID = INTAG.AVDID
> >AND
> >I.INSKRIVID = INTAG.INSKRIVID
> >;
>
>
> *Yahoo! Groups Sponsor*
> ADVERTISEMENT
> <http://rd.yahoo.com/M=237459.2675695.4055211.2225243/D=egroupweb/S=1705115386:HM/A=1267611/R=0/*http://ad.doubleclick.net/jump/N2524.Yahoo/B1071650;sz=300x250;ord=1037887154088478?>
>
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
> <http://docs.yahoo.com/info/terms/>.