Call a stored proc from a VIEW

I have a DB2 stored proc that returns a table (using an open cursor) whose layout depends on the input parameters.  

I would like to wrap the call to the stored proc in a view so users won't need to do the call themselves directly.  Is this possible?

Note:  it seems a table function won't work since the output table structure is not known in advance and varies depending on the input parameters.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kent OlsenDBACommented:
Hi Dr.

That's not allowed in DB2.  Perhaps the easiest work-around is to create a table function?

DrLechterAuthor Commented:
I don't think a table function will work either since the table structure is not known in advance and varies depending on input parameters.
Kent OlsenDBACommented:
What are you trying to do?  Backing up to the real need might help get to a workable solution.

DrLechterAuthor Commented:
We have a number of tables and views we want to allow various users to access.  Creating individual user accounts is not practical because of red tape in our processes.  We also cannot seem to use user groups or tie into AD because we're using some third party security programs which make this impossible or impractical.

We decided to create a stored proc to act as a gatekeeper to our tables and views.  The stored proc has its own application security tables.  We grant everyone access to execute the stored procedures through a single db2 account.  The users supply arguments for application login, password, and view name.  The stored proc authenticates the user, checks access rights to the view and then opens the view with a cursor to return the ds to the caller.  Since we administer the application security tables we can bypass the corporate red tape.

My concern is that some users may not know how/be able to to execute the stored proc.  I was hoping to provide a parameterized view as an alternative way to getting to the gatekeeper.
Kent OlsenDBACommented:
Instead of a parameterized view, can you use a function?

DB2 allows you to overload a function name, so you could have dozens of functions with the same name.  The functions are unique in that each one has a unique parameter list.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.