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

  • Home
  • SEARCH
  • 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 9267039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:27:25+00:00 2026-06-18T14:27:25+00:00

I have a trigger: CREATE TRIGGER BEFORE_DELETE_ON_SENTIERO__HA__TAPPA BEFORE DELETE ON SENTIERO__HA__TAPPA FOR EACH ROW

  • 0

I have a trigger:

CREATE TRIGGER BEFORE_DELETE_ON_SENTIERO__HA__TAPPA
BEFORE DELETE ON SENTIERO__HA__TAPPA
FOR EACH ROW 
BEGIN

DECLARE temp_prima_tappa INTEGER;
DECLARE temp_ultima_tappa INTEGER;

-- NOW THIS QUERY WILL FAIL;   it checks if the record that has to be deleted is in the table
IF NOT EXISTS ( SELECT *
                FROM SENTIERO__HA__TAPPA as sht
                WHERE OLD.IDsentiero=sht.IDsentiero and OLD.IDtappa=sht.IDtappa) THEN

                        SIGNAL SQLSTATE '45000'
                        SET MESSAGE_TEXT = 'DELETE: La tappa indicata non è nel sentiero; impossibile elimnarla';

END IF;

IDsentiero and IDtappa are PK of of their relative tables: IDsentiero for SENTIERO, IDtappa for TAPPA.

The problem is that the DELETE QUERY doesn’t reply me with that error message; simply it let runs DELETE QUERY, although it cannot delete anything, because that record doesn’t exist in the table.

The problem is that query.. i’m sure but i cannot find the bug.

  • 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-06-18T14:27:26+00:00Added an answer on June 18, 2026 at 2:27 pm

    Something like this should work:

    declare recsexist int;
    set recsexist = 0;  
    
    SELECT 1 INTO recsexist 
    FROM SENTIERO__HA__TAPPA as sht
    WHERE OLD.IDsentiero=sht.IDsentiero and OLD.IDtappa=sht.IDtappa;
    
    IF (recsexist > 0) THEN
         ...
    
    END IF; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

DELIMITER $$ CREATE TRIGGER before_insert_wall BEFORE INSERT ON wall FOR EACH ROW BEGIN DECLARE
I have the trigger: create or replace TRIGGER JACKET_DELETE BEFORE DELETE ON JACKET FOR
so I have the following query: CREATE TRIGGER `before_delete` BEFORE DELETE ON `abc` FOR
I have a table trigger like below: CREATE OR REPLACE TRIGGER PAT_BUR_DOB_TRG BEFORE UPDATE
is is possible in postgres to have a trigger on CREATE TABLE that will
I have a pretty simple trigger: CREATE OR REPLACE FUNCTION f_log_datei() RETURNS TRIGGER AS
I have a trigger that looks something like this: create or replace TRIGGER cluster_check
I have a trigger that check data before insert to another table IF NOT
i have this simple plpgsql function: CREATE FUNCTION update_times () RETURNS trigger AS '
I'm having some problems with mySQL triggers. I have this working: CREATE TRIGGER `insert_trigger`

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.