Solved

Select result from stored procedures in MS SQL

Posted on 1998-05-22
3
171 Views
Last Modified: 2010-04-06
Hi!
I've read that I can use stored procedures to speed up my
application. I made stored procedure like this:

create procedure MySelectProc @aDog int as
select * from Dogs where HeadID=@aDog
go

I placed TStoredProc on my TDataModule, set up properties, loaded all fields in the fields editor. When I do

MyExec..ParamByName('aDog').AsInteger := aDog;
MyExec.Open;

I don't recieve any set. MyExec is empty. ISQL/W gives to me result what I want

exec MySelectProc @aDog=10

Why I can't get my stored procedure result set.

(Delphi 3.0, MS SQL 6.5)
0
Comment
Question by:hansmtbank
  • 2
3 Comments
 
LVL 5

Expert Comment

by:ronit051397
ID: 1347459
As far as I know, in Stored procedures you have to create a temporary table and put the results in there.
0
 

Author Comment

by:hansmtbank
ID: 1347460
How do I do this?
Is this only one way to get results? It may be slow, and I can use  TQuery in my application.

TStoredProc + temporary table are slower than TQuery?
0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 100 total points
ID: 1347461
1. For SQL Servers use only TStoredProc and TQuery not TTable, recommanded by me    and Borland.
2. TQuery is faster and more reliable then TTable when it deals with SQL Servers and             large tables.
3. Use TQueries when you are doing simple and light 'Selectes'.
4. Use Stored procedures for heavy actions such as reports.
    After you genereted a result set in the stored procedure, do the following:
    - Create a table, SQL command: CREATE TABLE "SomeName"....
    - Fill that table with the results.
    - Put a TQuery and write in the sql:select * from "SomeName"...
    - If you want it to be temporary, then at some stage call the SQL command:
      DROP TABLE "SomeName"....
Don't write a Stored Procedure when you need to do a simple select, use TQuery instead. Use Stored procedures only when you need to write complex SQL programs.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…

685 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