May
8
2007
So Which is better a stored procedure or a cfc?
Posted by john at 5:01 PM
11 comments - Categories: Adobe
Posted by john at 5:01 PM
11 comments - Categories: Adobe
John wrote on 05/08/07 7:57 PM
this was a question I was asked in an interview. I responded by saying. in single homed application it would make sense to keep the logic inside a .cfc using inline queries for reuse. In a situation where you have many applications all accessing the same data source (c# programs, web apps, etc..) it would be best to maintain business logic in a stored procedure on the database as opposed to the application server.Raymond Camden wrote on 05/08/07 9:05 PM
Um, but that still isn't the point. You _can_ use stored procs as you describe. Just put the stored proc calls in the CFC.Sana wrote on 05/09/07 5:02 AM
Database engine are design for handling complex tasks, so simple anything which can run much better within db engine should not be in CFC.Raymond Camden wrote on 05/09/07 8:12 AM
Sana, you aren't getitng the point. Stored procedures have to go somewhere. Right? So put the _call_ in the CFC. I'm not talking about inline queries at all. I'm really shocked no one here is getting that. A CFC can use both inline queries or stored procs. You are right that it is a good thing to use stored procs, but using stored procs does NOT mean you don't use CFCs. It's apples and oranges people!Sana wrote on 05/09/07 8:38 AM
Correct me if I am wrong, I am talking about business logic which I clearly said that business logic can be split and could be implement in database section as well. I am aware of CFC can call stored_procedure + can have your business logic.Raymond Camden wrote on 05/09/07 8:51 AM
Maybe I'm just being too picky about language here. I get your point about putting the logic in the db. I'm not sure I agree (I think the db is great for queries but business rules belong in the app layer), but my main problem is how things are being worded here. You can absolutely put a heck of a lot of logic in the db layer and still use CFCs to call the db. The question isnt - "Do I use stored procs or CFCs", but "Do I put business logic in my db". Are you talking about _completely_ skipping CF? If so - I get your point, even if I don't agree. But if you are still talking about using CF then why would you NOT want your CFC to handle your calls to the db.Terrence Ryan wrote on 05/09/07 9:07 AM
I'll jump in here, and say that the best answers to this question start with "It depends."John wrote on 05/09/07 9:34 AM
I'll provide a little more context here.David Fekke wrote on 05/09/07 9:44 AM
John,android apps wrote on 12/16/11 2:16 AM
Great resources Wish i could find more info like this from others!
Raymond Camden wrote on 05/08/07 5:50 PM
Your question doesn't make sense. A stored procedure is a WAY to talk to the database. A CFC is a way to organize your code. So you can easily call a stored proc from within a CFC.