MySQL Forums
Forum List  »  Stored Procedures

Re: newbie: Stored proc silently fails
Posted by: Peter Brawley
Date: June 25, 2012 08:54PM

>> You saw that where?

>"The trigger cannot use statements that explicitly or implicitly begin or
> end a transaction such as START TRANSACTION, COMMIT, or ROLLBACK."

> http://dev.mysql.com/doc/refman/5.0/en/trigger-syntax.html

Read that sentence again again. It is about triggers and functions, not stored procedures.

> @id comes in through the "CALL"ing trigger

No it does not. A variable whose name begins with @ is a user variable. It does not refer to incoming parameters. If you want the sproc to use such a param, give it a name that distinguishes it from the involved column and write something like this ...

CREATE PROCEDURE `manage_sessions`(
  pid INT,              -- param name must differ from referenced column names
  pevent VARCHAR(8),    -- a good way to do that is to always name params
  pmachine VARCHAR(64), -- with a prefix like 'p'
  pline VARCHAR(64)
)
BEGIN
    DECLARE updateCount int(11) DEFAULT 0;
    -- SET @updateCount does not set the value of updatecount
    
    UPDATE
        sessions s,
        eventLog e
    SET
        s.end_id = pid  -- name of the incomping param
... etc

But why not implement this simple logic within the Trigger?

Options: ReplyQuote


Subject
Views
Written By
Posted
2448
June 25, 2012 02:28PM
1227
June 25, 2012 05:15PM
Re: newbie: Stored proc silently fails
1298
June 25, 2012 08:54PM
1172
June 25, 2012 11:52PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.