dbTalk Databases Forums  

Porting of Oracle cursor structure in T-SQL

microsoft.public.sqlserver.programming microsoft.public.sqlserver.programming


Discuss Porting of Oracle cursor structure in T-SQL in the microsoft.public.sqlserver.programming forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Gigio
 
Posts: n/a

Default Porting of Oracle cursor structure in T-SQL - 12-22-2004 , 10:35 AM






Hi,
I have a problem with a porting of a cursor structure in Oracle in SQL
Server 2000.
I need the same implementation of the functionalities.
The Oracle cursor structure is:

CURSOR SELECTOR_PHY_DISK IS
SELECT *
FROM DBS_PHYSICAL_DISKS
WHERE DBS_PHYSICAL_DISKS.PHYSICAL_DISK_ID = DISK_ID_P
FOR UPDATE;
physical_disk SELECTOR_PHY_DISK%ROWTYPE;

then I have an INSERT code, some like this:

.......etc...........
VALUES(physical_disk.physical_disk_id,
physical_disk.use,
physical_disk.type,
............etc......

But I've no idea how to write the same in T-SQL (maybe of varchar
type, but then I can't take the structure in the INSERT).
Have anyone ideas?
thanks

Reply With Quote
  #2  
Old   
John Bell
 
Posts: n/a

Default Re: Porting of Oracle cursor structure in T-SQL - 12-22-2004 , 10:59 AM






Hi

Depending on what you have to do between the fetch and the insert, you will
either have to declare a variable for each column or you may be able to use

INSERT INTO NewTable ( col1, col2... )
SELECT physical_disk_id,
physical_disk.use,
physical_disk.type,...
FROM physical_disk

For examples of a cursor see books online "Declare Cursor" topic.

John

"Gigio" <zambetti (AT) inwind (DOT) it> wrote

Quote:
Hi,
I have a problem with a porting of a cursor structure in Oracle in SQL
Server 2000.
I need the same implementation of the functionalities.
The Oracle cursor structure is:

CURSOR SELECTOR_PHY_DISK IS
SELECT *
FROM DBS_PHYSICAL_DISKS
WHERE DBS_PHYSICAL_DISKS.PHYSICAL_DISK_ID = DISK_ID_P
FOR UPDATE;
physical_disk SELECTOR_PHY_DISK%ROWTYPE;

then I have an INSERT code, some like this:

......etc...........
VALUES(physical_disk.physical_disk_id,
physical_disk.use,
physical_disk.type,
...........etc......

But I've no idea how to write the same in T-SQL (maybe of varchar
type, but then I can't take the structure in the INSERT).
Have anyone ideas?
thanks



Reply With Quote
Reply




Thread Tools
Display Modes

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

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.