LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-21-2006, 09:59 AM   #1
ati
Member
 
Registered: Oct 2005
Location: london
Distribution: fedora 4
Posts: 61

Rep: Reputation: 15
Cursor into Transaction or Query?


hi

i have this cursor and i would like to change it into a transactio or a Query, can some one help with please.

Code:
declare csr1 cursor
for select booking_no from holiday
for read only
 
begin tran
declare @holiday varchar(50)

open csr1

FETCH NEXT FROM csr1
INTO @holiday

-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN

SELECT @holiday as Booking, 
(select SUM(distance_in_miles)
from holiday, allocated, route_on_stage, stage
where holiday.booking_no = allocated.booking_no
and allocated.route_no = route_on_stage.route_no
and route_on_stage.stage_no = stage.stage_no
and holiday.booking_no = @holiday) as Distance,
(select SUM(cost_per_nite_per_person) * (
  SELECT number_of_clients FROM allocated, holiday, holiday_party
  WHERE holiday.booking_no = allocated.booking_no
  AND allocated.party_no = holiday_party.party_no
  AND holiday.booking_no = @holiday
) as total_cost
from holiday, allocated, route_on_stage, stage, accomdation, rooms
where holiday.booking_no = allocated.booking_no
and allocated.route_no = route_on_stage.route_no
and route_on_stage.stage_no = stage.stage_no
and stage.accomdation_at_end = accomdation.accomdation_name
and accomdation.accomdation_no = rooms.accomdation_no
and holiday.booking_no = @holiday) as Cost

   -- This is executed as long as the previous fetch succeeds.
   FETCH NEXT FROM csr1
   INTO @holiday
END

CLOSE csr1
DEALLOCATE csr1

commit tran
thanks for your time
 
Old 05-23-2006, 02:45 AM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Your qn is unclear; that is an SQL query (or at least the SELECT ... is).
You've got 'commit tran' at the end already, although it's unnecessary for SELECTs as no change is made to the DB.
Can you expand a bit?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hide mouse cursor/change cursor location? mrjamin Linux - Software 4 09-27-2010 10:09 AM
Could not open default cursor font 'cursor' at startx with slackware 10.2 bgryderclock Slackware 3 01-02-2006 10:36 PM
[Mouse cursor] flicking on animated cursor Creak Debian 1 06-10-2005 02:16 AM
Transaction Errors blackdragonblood Linux - Newbie 4 05-23-2005 10:12 PM
Changin cursor -obtaining cursor isaac_linux Linux - General 1 11-05-2003 12:48 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration