Solved

MS SQL DB-Library and Delphi

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

20 Experts available now in Live!

Get 1:1 Help Now