Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Posts
    3

    Unanswered: execption with store procedure

    HI!

    how do i make the store procudere only exec when new data inserted in the other table? recently i hav use sp_procoption to make an autoexecution..... but it will insert the new data together with the old data
    any suggestion?

    CREATE PROCEDURE [P1] AS

    INSERT INTO TABLE1

    SELECT sa.NoMatriks, sa.SesiSem,
    SUM(Nilai * KreditSubjek) / SUM(KreditSubjek) AS CPA,
    SUM(KreditSubjek) AS JumKredit,
    p.Agama, p.Aliran, p.Negeri, p.Kaum
    FROM TblSubjekAmbil sa, TblSubjek s, TblGred g, TblPelajar p
    WHERE sa.NoMatriks = p.NoMatriks AND
    sa.KodSubjek = s.KodSubjek AND
    sa.Gred = g.Gred
    GROUP BY sa.NoMatriks, sa.SesiSem,
    p.Agama, p.Aliran, p.Negeri,
    p.Kaum (SELECT sa.NoMatriks, t1.NoMatriks
    FROM TblSubjAmbil sa, TABLE1 t1
    WHERE t1.NoMatriks <> sa.NoMatriks)


    exec sp_makestartup N'P1'

    exec sp_makestartup N'P1'

    exec sp_makestartup N'P1'

  2. #2
    Join Date
    Aug 2003
    Location
    Delft, The Netherlands (EU)
    Posts
    447

    Re: execption with store procedure

    Databases have a great concept, called trigger. Just define an INSERT trigger for your table, and let that trigger execute your code or procedure.
    Make everything as simple as possible, but not simpler! - A. Einstein
    DB Problems? DB Explorer, BTrieve Re-engineering, DB Conversions & ETL? Conversion Tool

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •