Solved

Return values from sp

Posted on 2000-04-27
11
666 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JAudiorecorder record freezing the app 29 93
shape, triangle, dbctrlgrid 3 47
Add New Database Table in database file using delphi 3 54
Broadcast a message using ICS 2 51
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

710 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