Subject Re: Exception handling
Author fantomen66
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
;




--- In ib-support@y..., Svein Erling Tysvaer
<svein.erling.tysvaer@k...> wrote:
> Swedish Phantom,
> what surprises me is that you do this in a procedure and not in a
before
> insert/before update trigger.
>
> Set
>
> At 12:22 21.11.2002 +0000, you wrote:
> >I have creatd the following store procedure:
> >
> >SET TERM ^ ;
> >CREATE PROCEDURE SANGPLATSER
> >(AVDID INTEGER, KON CHAR(1))
> >RETURNS
> >(TOTAL_SANGER CHAR(10))
> >AS
> >BEGIN
> >SELECT COUNT(PERSNR) FROM VY_SANGPLATSER
> >WHERE
> >AVDID = :AVDID
> >AND
> >KON = :KON
> >INTO :TOTAL_SANGER;
> >EXIT;
> >END^
> >SET TERM ; ^
> >
> >What i actually want to do is to control if the count on colum
> >(PERSNR) > 20 then
> >initiate a exception called SANGER displaying the following
> >message 'No more beds'
> >
> >How should i change my current store procedure and also have the
> >exception inside the stored procedure.