Solved

Return values from sp

Posted on 2000-04-27
11
660 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
A short film showing how OnPage and Connectwise integration works.

919 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

21 Experts available now in Live!

Get 1:1 Help Now