MySQL Forums
Forum List  »  Triggers

Re: Error in Trigger creation
Posted by: Peter Brawley
Date: June 16, 2017 11:14AM

First, you need to read the manual page for Triggers. A Trigger can't execute Insert or Update or Delete on the table it's defined for. Use the keyword NEW to change values.

Second, SELECT count(cus_id) INTO @ct is malformed SQL. For the count of customer.cus_id values you need something like ...

set @ct = ( select count(cus_id) from customer );

Third, what problem is solved by basing a new customer.cus_id on the row count and rand()? If you really need foolproof pseudoandom unique IDs, why not use UUID()? Otherwise what is it about the requirement that rules out auto_increment?

Options: ReplyQuote


Subject
Views
Written By
Posted
734
June 16, 2017 06:46AM
Re: Error in Trigger creation
284
June 16, 2017 11:14AM


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.