473,320 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Stored procedure calling another stored procedure_

Hi all,

I have a stored procedure that return a resultset
e.g. stored proc: get_employee_details
select emp_id, emp_name, emp_salary, emp_position
from empoloyee

I would like to write another stored procedure that executes the above
stored procedure - returning the same number of records but it will
only show 2 columns
e.g. new stored proc: get_employee_pay -- executes
get_employee_details
I only need to know emp_id, emp_salary.

How can this be done in sql stored procedure?

Thanks,
June Moore.
Jul 20 '05 #1
2 28037
June,

I would make the first stored proc a UDF (user defined function) that
returns a table. This allows the second stored proc to use the UDF in the
From clause as if it were a table. You can then extract just the fields you
need in the Select statement. For example:

The second stored proc would contain the following SQL:

Select emp_id, emp_salary
From get_employee_details (assumes get_employee_details is a Table-Values
UDF)

See "Rewriting Stored Procedures as Functions" in BOL

J.R.
Largo SQL Tools
The Finest Collection of SQL Tools Available
http://www.largosqltools.com

"June Moore" <ju******@yahoo.com.au> wrote in message
news:e5**************************@posting.google.c om...
Hi all,

I have a stored procedure that return a resultset
e.g. stored proc: get_employee_details
select emp_id, emp_name, emp_salary, emp_position
from empoloyee

I would like to write another stored procedure that executes the above
stored procedure - returning the same number of records but it will
only show 2 columns
e.g. new stored proc: get_employee_pay -- executes
get_employee_details
I only need to know emp_id, emp_salary.

How can this be done in sql stored procedure?

Thanks,
June Moore.

Jul 20 '05 #2
[posted and mailed, please reply in news]

June Moore (ju******@yahoo.com.au) writes:
I have a stored procedure that return a resultset
e.g. stored proc: get_employee_details
select emp_id, emp_name, emp_salary, emp_position
from empoloyee

I would like to write another stored procedure that executes the above
stored procedure - returning the same number of records but it will
only show 2 columns
e.g. new stored proc: get_employee_pay -- executes
get_employee_details
I only need to know emp_id, emp_salary.

How can this be done in sql stored procedure?


I have an article on my web site that discusses this:
http://www.algonet.se/~sommar/share_data.html.

--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my...
5
by: Warren Wright | last post by:
Hi group, I have a select statement that if run against a 1 million record database directly in query analyzer takes less than 1 second. However, if I execute the select statement in a stored...
0
by: Rhino | last post by:
I've written several Java stored procedures now (DB2 V7.2) and I'd like to write down a few "best practices" for reference so that I will have them handy for future development. Would the...
4
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
3
by: louise raisbeck | last post by:
Hi i have a strange problem. I have a stored procedure which inserts a new row and for one of the values gets a max of a number, adds 1 to it, then puts this in an integer field. Probably easier if...
2
by: singlal | last post by:
Hi, my question was not getting any attention because it moved to 2nd page; so posting it again. Sorry for any inconvenience but I need to get it resolved fast. Need your help! ...
9
by: fniles | last post by:
I am using VB.NET 2003 and SQL2000 database. I have a stored procedure called "INSERT_INTO_MYTABLE" that accepts 1 parameter (varchar(10)) and returns the identity column value from that table....
0
by: pompeyoc | last post by:
I am trying to learn how to use stored procedures written in COBOL so I wrote 2 small programs to test it out: the stored procedure and the the calling program. I have no problems compiling them...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.