MySQL Forums
Forum List  »  Stored Procedures

Re: CALL in stored procedure doesn't work
Posted by: Peter Brawley
Date: February 08, 2015 03:32PM

> When author hasn't articles, than table must have fake relation:(uid, -1)

Terrible idea. It complicates almost every operation that you can perform upon a table, because 99% of the time your application must pretend this row doesn't exist. Almost every SELECT statement will require modification. Suddenly you need special logic to handle these "special" non-existent rows. You can never permit the deletion of any row whose PK is fake. And finally, this solution is based on a misunderstanding of basic relational principles. Redesign without the fake IDs.

Two stages in debugging database logic in sprocs ...

1. Debug each step outside the sproc in the mysql client till they all work.

2. Then assemble the sproc from the debugged atomic statements, add handlers and signal stubs, eg ...

  begin
    declare exit handler for sqlexception  -- or not found, or an error that you define
      begin
        signal sqlstate value '99999' set message_text='your err msg here';
      end;
    select 'running' as 'block 1';
    -- your code here ...
  end;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: CALL in stored procedure doesn't work
1320
February 08, 2015 03:32PM


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.