Solved

Return values from sp

Posted on 2000-04-27
11
654 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
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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now