From: Daniel Kasak Date: January 3 2006 9:14pm Subject: Re: MySql 5 replacement for computed default column value List-Archive: http://lists.mysql.com/mysql/193460 Message-Id: <43BAE922.3040303@nusconsulting.com.au> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Harald Fuchs wrote: >In article <43B99C1E.8080401@stripped>, >Daniel Kasak writes: > > > >>Bryan Cantwell wrote: >> >> >>>Trying to migrate to MySql 5 from Sybase asa. I have a tables that >>>have column values that are calculated based on other columns in the >>>table. How can I accomplish the same in MySql? >>> >>> >>> >>This sounds a job for a trigger - an insert trigger. >>I haven't used triggers in mysql, so I can't help you with exactly how >>to do it. >> >> > >If SELECT performance is good enough, a VIEW would probably be easier. > > > The advantage of a trigger is that it only runs when the data is inserted ( and possibly updated ). Depending on the use of the database, you may have a situation where the data is inserted and then selected from multiple times - that's at least the usage pattern we have here. In this case, you're better off with a stored procedure. Also keep in mind that the title of the post said 'default', indicating that the fields in question might take on a different value to the calculated one. -- Daniel Kasak IT Developer NUS Consulting Group Level 5, 77 Pacific Highway North Sydney, NSW, Australia 2060 T: (+61) 2 9922-7676 / F: (+61) 2 9922 7989 email: dkasak@stripped website: http://www.nusconsulting.com.au