Jump to content
Fórum Script Brasil
  • 0

Triggers no ibconsole 6.5


hudsmar

Question

Boa tarde.

Estou com um probleminha, não consigo rodar essa trigger no ibconsole 6.5

CREATE TRIGGER Apaga_Medidas_Pagamentos for Aluno

FOR DELETE

AS

DELETE Medidas

FROM Medidas m INNER JOIN Deleted d

ON m.COD_ALU = d.COD_ALU

DELETE Pagamento

FROM Pagamento p INNER JOIN Deleted d

ON p.COD_ALU = d.COD_ALU

/**********************************************************************/

GO

/**********************************************************************/

CREATE TRIGGER Novo_Vencimento

ON Pagamento

FOR INSERT

AS

DECLARE @DATA DateTime,

@DATANOVA DateTime

SET @DATA = (Select A.DATA_VENC FROM Aluno A INNER JOIN Inserted i ON A.COD_ALU = i.COD_ALU)

SET @DATANOVA = Dateadd(m,1,@DATA)

UPDATE Aluno

SET DATA_VENC = @DATANOVA

FROM Aluno a INNER JOIN Inserted i

ON a.COD_ALU = i.COD_ALU

/**********************************************************************/

GO

/**********************************************************************/

CREATE TRIGGER TotMensal_DtVenc

ON Aluno

FOR INSERT

AS

DECLARE @1 Decimal(12,2), @2 Decimal(12,2), @3 Decimal(12,2), @4 Decimal(12,2), @5 Decimal(12,2),

@6 Decimal(12,2), @CODIGO int, @TOTAL Decimal(12,2)

SET @CODIGO =(SELECT a.COD_ALU FROM Aluno a, Inserted i WHERE a.COD_ALU = i.COD_ALU)

SET @1= (SELECT M.MENSALIDADE FROM ALUNO A, MODALIDADE M WHERE A.COD_MOD1 = M.COD_MOD AND COD_ALU = @CODIGO)

SET @2= (SELECT M.MENSALIDADE FROM ALUNO A, MODALIDADE M WHERE A.COD_MOD2 = M.COD_MOD AND COD_ALU = @CODIGO)

SET @3= (SELECT M.MENSALIDADE FROM ALUNO A, MODALIDADE M WHERE A.COD_MOD3 = M.COD_MOD AND COD_ALU = @CODIGO)

SET @4= (SELECT M.MENSALIDADE FROM ALUNO A, MODALIDADE M WHERE A.COD_MOD4 = M.COD_MOD AND COD_ALU = @CODIGO)

SET @5= (SELECT M.MENSALIDADE FROM ALUNO A, MODALIDADE M WHERE A.COD_MOD5 = M.COD_MOD AND COD_ALU = @CODIGO)

SET @6= (SELECT M.MENSALIDADE FROM ALUNO A, MODALIDADE M WHERE A.COD_MOD6 = M.COD_MOD AND COD_ALU = @CODIGO)

IF @1 IS Null Set @1 = 0

IF @2 IS Null Set @2 = 0

IF @3 IS Null Set @3 = 0

IF @4 IS Null Set @4 = 0

IF @5 Is Null Set @5 = 0

IF @6 Is Null Set @6 = 0

SET @TOTAL = (@1+@2+@3+@4+@5+@6)

UPDATE Aluno

SET VLR_DEVIDO = @TOTAL,

DATA_VENC = a.DATA_CAD

FROM Aluno a, Inserted i

WHERE i.COD_ALU = a.COD_ALU

/**********************************************************************/

GO

/**********************************************************************/

CREATE TRIGGER Altera_Mensalidade

ON Aluno

FOR UPDATE

AS

DECLARE @1 Decimal(12,2), @2 Decimal(12,2), @3 Decimal(12,2), @4 Decimal(12,2), @5 Decimal(12,2),

@6 Decimal(12,2), @CODIGO int, @TOTAL Decimal(12,2)

SET @CODIGO =(SELECT a.COD_ALU FROM Aluno a, Inserted i WHERE a.COD_ALU = i.COD_ALU)

SET @1= (SELECT M.MENSALIDADE FROM ALUNO A, MODALIDADE M WHERE A.COD_MOD1 = M.COD_MOD AND COD_ALU = @CODIGO)

SET @2= (SELECT M.MENSALIDADE FROM ALUNO A, MODALIDADE M WHERE A.COD_MOD2 = M.COD_MOD AND COD_ALU = @CODIGO)

SET @3= (SELECT M.MENSALIDADE FROM ALUNO A, MODALIDADE M WHERE A.COD_MOD3 = M.COD_MOD AND COD_ALU = @CODIGO)

SET @4= (SELECT M.MENSALIDADE FROM ALUNO A, MODALIDADE M WHERE A.COD_MOD4 = M.COD_MOD AND COD_ALU = @CODIGO)

SET @5= (SELECT M.MENSALIDADE FROM ALUNO A, MODALIDADE M WHERE A.COD_MOD5 = M.COD_MOD AND COD_ALU = @CODIGO)

SET @6= (SELECT M.MENSALIDADE FROM ALUNO A, MODALIDADE M WHERE A.COD_MOD6 = M.COD_MOD AND COD_ALU = @CODIGO)

IF @1 IS Null Set @1 = 0

IF @2 IS Null Set @2 = 0

IF @3 IS Null Set @3 = 0

IF @4 IS Null Set @4 = 0

IF @5 Is Null Set @5 = 0

IF @6 Is Null Set @6 = 0

SET @TOTAL = (@1+@2+@3+@4+@5+@6)

UPDATE Aluno

SET VLR_DEVIDO = @TOTAL

FROM Aluno a INNER JOIN Inserted i

ON a.COD_ALU = i.COD_ALU

só falta fazer rodas isso para meu programa funcionar..

se alguém poder me ajudar.. agradeçerria muito

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      652k
×
×
  • Create New...