Hi all,
I have a stored procedure that return a resultset
e.g. stored proc: get_employee_de tails
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_pa y -- executes
get_employee_de tails
I only need to know emp_id, emp_salary.
How can this be done in sql stored procedure?
Thanks,
June Moore. 2 28055
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_de tails (assumes get_employee_de tails 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.goo gle.com... Hi all,
I have a stored procedure that return a resultset e.g. stored proc: get_employee_de tails 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_pa y -- executes get_employee_de tails I only need to know emp_id, emp_salary.
How can this be done in sql stored procedure?
Thanks, June Moore.
[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_de tails 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_pa y -- executes get_employee_de tails 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 application
server can talk to the database.
I've determined the failure occurs when the the following statement is
executed: cstmt.execute(); (due to the failure of println statements
placed afterwards). I get the following error after trying to...
|
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 procedure
instead, calling the stored proc from query analyzer, then it takes
12-17 seconds.
Here is what I execute in Query Analyzer when bypassing the stored
procedure:
|
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 experts here agree with the following? Would they add any other
points?
1. If the shop standard calls for logging of application errors, a stored
procedure should log any error that it encounters immediately upon detecting
it and then return to the...
|
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 Throwable as an OUT
parameter and what datatype should I use in the CREATE PROCEDURE and DROP
PROCEDURE statements?
Here's what I tried:
- the method signature for the stored procedure included: Throwable
throwable
|
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 problems doing this.
I wanted to implemented a generic "Helper" class like this:
/**
* Helper
| |
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 i paste it.
CREATE PROCEDURE dbo.sp_NewRef
AS
declare @nextnum int
SELECT @nextnum = max((anothernumber) + 1) from tblx
INSERT INTO tblx (reference) VALUES (@nextnum);SELECT SCOPE_IDENTITY()
|
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!
****************************************************************************************************
Original Question:
--------------------
Has anyone called a COBOL subroutine using COBOL CALL from a COBOL/DB2
|
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.
When calling the stored procedure from VB.NET, in the CommandText, can I
just say "INSERT_INTO_MYTABLE '12345'" instead of calling it with
"INSERT_INTO_MYTABLE" then do the following :
OleDbCommand2.Parameters.Add("@Account", SqlDbType.VarChar, 10)...
|
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 but when the
calling program enters the SP, it either hangs or gives me sqlcode
-1131.
We are on AIX 5.2 (I think) running DB2 UDB ver 7.2 and MF COBOL 4.1.
Below are the programs I wrote:
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |