Solved

Return values from sp

Posted on 2000-04-27
11
669 Views
Last Modified: 2012-06-21
I have an SQL Server stored procedure that execute SELECT with COMPUTE SQL statement. How can I retrieve data returned in compute part. I'm using Delphi 5 and TAdoStoredPRocedure to execute Sp.
SQL Statement looks like:
SELECT  id,duration,cost,revenue from table a
COMPUTE SUM(duration),sum(cost),sum(revenue)
0
Comment
Question by:pvs001d
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 1

Expert Comment

by:l8knight
ID: 2755827
You don't say which SQL server you are using but with interbase stored procedures are like this. I believe the RETURNS section is what your after.

extract from Interbase Docs...

CREATE PROCEDURE procedure_name
[( input_var1 datatype[ , input_var2 datatype …])]
[RETURNS ( output_var1 datatype[, output_var2 datatype …])]
AS
BEGIN
statements in InterBase procedure and trigger language
END

hope it helps

regards

l8knight
0
 
LVL 4

Expert Comment

by:Radler
ID: 2757562
Listening...
0
 

Author Comment

by:pvs001d
ID: 2758156
I'm using MS SQL Server . You probably misunderstoood my question. I need DELPHI syntax to get values that are returned by sp in multiple recordsets.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 10

Expert Comment

by:ECollin
ID: 2758541
You can use a TQuery to retreive the result of your sp.

It could be something like that :
myQry.SQL.Text := 'Select * from sp_YOUR_SP';
myQry.Open;
myQry.First;
While not myQry.EoF do
  Begin
  ...
  myQry.Next;
  End;
....
0
 

Author Comment

by:pvs001d
ID: 2759095
Guys,
please read the question before posting comments! I don't want to construct a query, I already have a stored procedure that (I think ) returns MULTIPLE recordsets . My problem is - how to get to the second, third ,etc recordsets using ADO.
0
 
LVL 1

Expert Comment

by:DValery
ID: 2759176
What SQL Server do you use?
0
 
LVL 1

Accepted Solution

by:
XAN earned 100 total points
ID: 2760578
 Recordset2 := Recordset1.NextRecordset;
....
0
 

Author Comment

by:pvs001d
ID: 2821455
XAN , please lock the question. (Your answer might have been more detailed, though)
0
 
LVL 15

Expert Comment

by:simonet
ID: 2925927
You can accept his answer w/o him lock the question. Just click on "accept comment as answer" on the header of his comment.
0
 

Expert Comment

by:magico
ID: 3021579
CREATE PROCEDURE spGetValueAndRecords
@CalcValue OUTPUT
AS

SELECT * FROM table
SELECT @CalcValue = SUM(value) FROM table


In Delphi
you add a TAdoStoredPRocedure, you open it, check the params and you'll see @CalcValue as Input/Output, change it to OutPut if you'll not use it to input values.

After Open you'll access @CalcValue as a regular param but for getting the paramvalue, not setting

Regards,
0
 

Author Comment

by:pvs001d
ID: 3431330
Comment accepted as answer
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses
Course of the Month5 days, 4 hours left to enroll

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question