Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2012
    Posts
    3

    Unanswered: Trigger subselect doesnt work

    Hello,

    i write a insert, update, delete, trigger for writing a Timestamp in a seperat table.
    I use a subselect to verify the the Mprimary Key isnt existent, but the subselect doesnt work.
    When i use the subselect as normal select on my console, then it works.
    When i do the select in the Trigger with a hardcoded id it doesnt work.
    For an insert the same subselect works.
    I hope someone can give me a hint

    Regards Stefan

    Example:
    Code:
    CREATE TRIGGER
    changeCommit
    ON domain
    FOR INSERT,UPDATE,DELETE
    
    as
    
    BEGIN
    -- Declare Vars / cursor
    .
    .
    SELECT 1 FROM table1, table2, targettable
                                     WHERE table1.id=13246876
                                     AND table1.id=table2.id                                            
                                     AND table2.id=targettable.id
    
    
    while
    begin
                 IF EXISTS (SELECT 1 FROM table1, table2, targettable
                                     WHERE table1.id=@cursorvariable
                                     AND table1.id=table2.id                                            
                                     AND table2.id=targettable.id)
    begin
    
    aktion
    
    else 
    
    other aktion
    end
    
    end

  2. #2
    Join Date
    Sep 2012
    Posts
    3
    Found Solution:
    Sybase only knows after Trigger, first do the delete, then the aktion and my select will failfor not existing id, grrrr.

    regards Stefan

Posting Permissions

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