Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7567931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:47:38+00:00 2026-05-30T14:47:38+00:00

I am writing a trigger in a Sybase ASE database which fires on a

  • 0

I am writing a trigger in a Sybase ASE database which fires on a update and compares the value before and after the update. I do this to verify if the update has actually changed the data. If this is the case it adds a row to a monitoring table. Unfortunately the trigger only works if the update command only affects 1 row. If it is affecting more than one row i get this error:

Msg 512, Level 16, State 5:
Server 'myserver', Procedure 'myproc', Line 2:
Subquery returned more than 1 value.  This is illegal when the subquery follows =, !=, <, <= , >, >=, or when the subquery is used as an expression.

my proc looks like this:

create trigger mytrigger on mytable for update as

set nocount on

/* now do the insert if colum was updated  */
if update(col_a) and (select col_a from inserted) not in (select col_a from deleted) 
begin
    insert into monitoring_table (login,tablename,field,action,pstamp) 
        select suser_name(),'mytable','col_a','U',getdate() from inserted
end
/* now do the insert if colum was updated  */
if update(col_b) and (select col_b from inserted) not in (select col_b from deleted) 
begin
    insert into monitoring_table (login,tablename,field,action,pstamp) 
        select suser_name(),'mytable','col_b','U',getdate() from inserted
end
go

any idea how i can get around this multi update problem within my trigger?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T14:47:39+00:00Added an answer on May 30, 2026 at 2:47 pm

    if the error is in trigger then the following should work:
    instead of:

    if update(col_a) and (select col_a from inserted) not in (select col_a from deleted)
    

    use

    if update(col_a) and exists (select col_a from inserted where col_a not in (select col_a from deleted))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a Oracle trigger. This trigger should automatically set the value of
I have an AFTER INSERT OR UPDATE OR DELETE trigger that I'm writing to
I am writing a trigger on update but i get this error Save error:
I tried writing this small trigger in MySQL, CREATE TRIGGER `leg` BEFORE INSERT ON
This posting is an update (with trigger code) from my earlier posting yesterday I
I'm writing a trigger that will do a cross table update, but I can't
I have a Postgres database (9) that I am writing a trigger for. I
I'm writing this application which is a flashcard app, I would like to create
I am writing a trigger and i need 2 tables. new/old which already exist
I need help writing a MySQL trigger. Suppose you have a student database with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.