StrataFrame Forum

How to: using parameterized Views with BO

http://forum.strataframe.net/Topic24117.aspx

By Edhy Rijo - 8/4/2009

I have the need to grab some records from 3 tables to do a lengthy process which includes looping that resulting query doing some seeks, etc. I am thinking that since this involve 3 tables that I could create a parameterized view in the DDT and then create a BO based on this view, now here is the question: How to fill this BO and pass the parameters to the view?



If you can post a quick seudo code I would really appreciate it, or if it is a better, easier solution that does not required to use a view, I am more than happy to listen. Smile



I am thinking on using a BO to take advantage of the BO features for Seek, Order, etc, since I may need to loop through this data several times.



Thanks!
By Peter Jones - 8/4/2009

Hi Edhy,



I don't use the DDT so I don't know what facilities it offers but, within SQL Server, there is no such thing as a parameterised view. I believe you will be forced to use a stored procedure. However, I do remember seeing references to a creature called an 'inline function' that apparently can operate like an a parameterised view - I guess an inline function may be useful when stored procedures are not an option for some reason.



Cheers, Peter
By Peter Jones - 8/4/2009

Hi Edhy,



Oops, clicked Post too soon.



What you could do is create a view upon which your BO is based but populate the BO using a stored procedure. It does mean you have to keep the view and proc in sync regarding what data columns are returned but I presume the data returned wouldn't change to often (if at all).



Cheers, Peter
By Edhy Rijo - 8/4/2009

Thanks a lot Peter, I will follow your instructions and test with the View and a Store Procedure with the parameters.
By Edhy Rijo - 8/4/2009

Peter Jones (08/04/2009)
What you could do is create a view upon which your BO is based but populate the BO using a stored procedure.


Yeap, you are right, it does work. Besides the possible inconvenience of having to maintain these 2 related objects, in my case the benefits of been able to use a BO to manipulate the data in this process make it worth the downside.



Thanks again for the steps and clarifications.
By Trent L. Taylor - 8/6/2009

Peter, thanks. Parameterized views were in VFP, but ultimately serve no real purpose since a SPROC is the mecahnism from which this type of this should be done. Glad you got it going.