Solved

MS SQL DB-Library and Delphi

Posted on 1998-08-31
1
299 Views
Last Modified: 2010-04-03
Does anybody out there has an example of the use of cursors with MSSQL 6.x DB-Library from Delphi?.

I'll apreciate some help.
0
Comment
Question by:Mak042298
[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
1 Comment
 

Accepted Solution

by:
ltw earned 100 total points
ID: 1338255
I have used Delphi with Sybase which is or was virtually identical to MS-SQL at this level at least.  I don't remember ever needing to use SQL cursors directly in Delphi apps (since Delphi does it for you) but I frequently used them in SQL triggers and stored procedures.  If that is what you want to do, here is a brief (and somewhat silly) example from a stored procedure:

 declare @custid numeric(9,0)
 select @custid = 12345
 declare @oid    numeric(9,0)
 declare mycursor cursor for
     select order_id from orders where cust_id = @custid
 open mycursor
 fetch mycursor into @oid
 while (@@sqlstatus = 0)
   begin
     /* do something with the data such as insert  
        into another table */
     insert into custorders values (@custid,@oid)

     /* move the cursor to the next row of the result */
     fetch order_cursor into @oid
   end
 close mycursor
 deallocate cursor mycursor


0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
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…

733 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