Solved

Select result from stored procedures in MS SQL

Posted on 1998-05-22
3
163 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

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…
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…
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.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

706 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

19 Experts available now in Live!

Get 1:1 Help Now