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
Solved

Select result from stored procedures in MS SQL

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

856 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