Solved

MS SQL DB-Library and Delphi

Posted on 1998-08-31
1
298 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
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

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

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…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

792 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