Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Multiple Cursor use in one batch

6 posts in General Discussion Last posting was on 2003-08-12 20:39:47.0Z
JacobT Posted on 2003-08-12 15:59:49.0Z
Sender: 347a.3f390e81.1804289383@sybase.com
From: JacobT
Newsgroups: ianywhere.public.general
Subject: Multiple Cursor use in one batch
X-Mailer: WebNews to Mail Gateway v1.1s
Message-ID: <3f390ef5.348f.846930886@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 12 Aug 2003 08:59:49 -0700
X-Trace: forums-1-dub 1060703989 10.22.241.41 (12 Aug 2003 08:59:49 -0700)
X-Original-Trace: 12 Aug 2003 08:59:49 -0700, 10.22.241.41
Lines: 5
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:1571
Article PK: 3800

I'm am trying to write a script that uses multiple cursors
but for some reason I am having trouble now that I have
added a second cursor. Is there some special thing that I
have to do when declaring a second cursor in the same
script?


Reg Domaratzki Posted on 2003-08-12 17:11:15.0Z
From: "Reg Domaratzki" <Spam_bad_rdomarat@ianywhere.com>
Newsgroups: ianywhere.public.general
References: <3f390ef5.348f.846930886@sybase.com>
Subject: Re: Multiple Cursor use in one batch
Lines: 56
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: rdomarat-pc.sybase.com
X-Original-NNTP-Posting-Host: rdomarat-pc.sybase.com
Message-ID: <3f391fb3$1@forums-1-dub>
Date: 12 Aug 2003 10:11:15 -0700
X-Trace: forums-1-dub 1060708275 172.31.143.163 (12 Aug 2003 10:11:15 -0700)
X-Original-Trace: 12 Aug 2003 10:11:15 -0700, rdomarat-pc.sybase.com
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:1573
Article PK: 3802

What trouble are you having? An error message would go a long way in trying
to figure out what's wrong.

The following procedure works great for me :

create procedure ProcessAdmin ()
begin
DECLARE CurInsert CURSOR FOR SELECT admin_id, data FROM Admin_Process
WHERE row_type = 'I';
DECLARE CurUpdate CURSOR FOR SELECT admin_id, data FROM Admin_Process
WHERE row_type = 'U' ;
DECLARE CurDelete CURSOR FOR SELECT admin_id, data FROM Admin_Process
WHERE row_type = 'D';
DECLARE cid INTEGER;
DECLARE cdata VARCHAR(30);
OPEN CurInsert;
FETCH FIRST CurInsert INTO cid, cdata;
WHILE ( sqlcode = 0 ) LOOP
INSERT INTO Admin VALUES (cid,cdata,DEFAULT);
FETCH NEXT CurInsert INTO cid,cdata;
END LOOP;
CLOSE CurInsert;
OPEN CurUpdate;
FETCH FIRST CurUpdate INTO cid, cdata;
WHILE ( sqlcode = 0 ) LOOP
UPDATE Admin SET data = cdata WHERE admin_id = cid;
FETCH NEXT CurUpdate INTO cid,cdata;
END LOOP;
CLOSE CurUpdate;
OPEN CurDelete;
FETCH FIRST CurDelete INTO cid, cdata;
WHILE ( sqlcode = 0 ) LOOP
DELETE FROM Admin WHERE admin_id = cid;
FETCH NEXT CurDelete INTO cid,cdata;
END LOOP;
CLOSE CurDelete;
END;

--
Reg Domaratzki, Sybase iAnywhere Solutions
Sybase Certified Professional - Sybase ASA Developer Version 8
Please reply only to the newsgroup

iAnywhere Developer Community : http://www.ianywhere.com/developer
ASA Patches and EBFs : http://downloads.sybase.com/swx/sdmain.stm
-> Choose SQL Anywhere Studio
-> Set "Platform Preview" and "Time Frame" to ALL

<JacobT> wrote in message news:3f390ef5.348f.846930886@sybase.com...
> I'm am trying to write a script that uses multiple cursors
> but for some reason I am having trouble now that I have
> added a second cursor. Is there some special thing that I
> have to do when declaring a second cursor in the same
> script?


JacobT Posted on 2003-08-12 17:42:17.0Z
Sender: 58c9.3f39260b.1804289383@sybase.com
From: JacobT
Newsgroups: ianywhere.public.general
Subject: Re: Multiple Cursor use in one batch
X-Mailer: WebNews to Mail Gateway v1.1s
Message-ID: <3f392711.58e2.846930886@sybase.com>
References: <3f390ef5.348f.846930886@sybase.com><3f391fb3$1@forums-1-dub>
X-Original-NNTP-Posting-Host: 10.22.241.42
X-Original-Trace: 12 Aug 2003 10:42:41 -0700, 10.22.241.42
Lines: 70
NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
Date: 12 Aug 2003 10:42:17 -0700
X-Trace: forums-1-dub 1060710137 10.22.241.42 (12 Aug 2003 10:42:17 -0700)
X-Original-Trace: 12 Aug 2003 10:42:17 -0700, forums-2-dub.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:1574
Article PK: 3803

Well, right now I'm just trouble shooting the second cursor
and I have the second cursor declared, then I have the open
statement, Fetch statement, followed by my commented out
code(for debugging purposes) and then closed off by my close
statement. but as soon as it get to the fetch statement in
that second cursor it says cursor not open. If I comment out
the Fetch and just go from Open to Close it gives me the
same error. Is it a problem to have to two cursors open at
once? My first cursor is going through my first query while
the second cursor is going through a sub query of the first
one.

> What trouble are you having? An error message would go a
> long way in trying to figure out what's wrong.
>
> The following procedure works great for me :
>
> create procedure ProcessAdmin ()
> begin
> DECLARE CurInsert CURSOR FOR SELECT admin_id, data FROM
> Admin_Process WHERE row_type = 'I';
> DECLARE CurUpdate CURSOR FOR SELECT admin_id, data FROM
> Admin_Process WHERE row_type = 'U' ;
> DECLARE CurDelete CURSOR FOR SELECT admin_id, data FROM
> Admin_Process WHERE row_type = 'D';
> DECLARE cid INTEGER;
> DECLARE cdata VARCHAR(30);
> OPEN CurInsert;
> FETCH FIRST CurInsert INTO cid, cdata;
> WHILE ( sqlcode = 0 ) LOOP
> INSERT INTO Admin VALUES (cid,cdata,DEFAULT);
> FETCH NEXT CurInsert INTO cid,cdata;
> END LOOP;
> CLOSE CurInsert;
> OPEN CurUpdate;
> FETCH FIRST CurUpdate INTO cid, cdata;
> WHILE ( sqlcode = 0 ) LOOP
> UPDATE Admin SET data = cdata WHERE admin_id = cid;
> FETCH NEXT CurUpdate INTO cid,cdata;
> END LOOP;
> CLOSE CurUpdate;
> OPEN CurDelete;
> FETCH FIRST CurDelete INTO cid, cdata;
> WHILE ( sqlcode = 0 ) LOOP
> DELETE FROM Admin WHERE admin_id = cid;
> FETCH NEXT CurDelete INTO cid,cdata;
> END LOOP;
> CLOSE CurDelete;
> END;
>
> --
> Reg Domaratzki, Sybase iAnywhere Solutions
> Sybase Certified Professional - Sybase ASA Developer
> Version 8 Please reply only to the newsgroup
>
> iAnywhere Developer Community :
> http://www.ianywhere.com/developer ASA Patches and EBFs :
> http://downloads.sybase.com/swx/sdmain.stm
> -> Choose SQL Anywhere Studio
> -> Set "Platform Preview" and "Time Frame" to ALL
>
> <JacobT> wrote in message
> > news:3f390ef5.348f.846930886@sybase.com... I'm am trying
> > to write a script that uses multiple cursors but for
> > some reason I am having trouble now that I have added a
> > second cursor. Is there some special thing that I have
> > to do when declaring a second cursor in the same script?
>
>


Reg Domaratzki Posted on 2003-08-12 17:53:42.0Z
From: "Reg Domaratzki" <Spam_bad_rdomarat@ianywhere.com>
Newsgroups: ianywhere.public.general
References: <3f390ef5.348f.846930886@sybase.com><3f391fb3$1@forums-1-dub> <3f392711.58e2.846930886@sybase.com>
Subject: Re: Multiple Cursor use in one batch
Lines: 109
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: rdomarat-pc.sybase.com
X-Original-NNTP-Posting-Host: rdomarat-pc.sybase.com
Message-ID: <3f3929a6$1@forums-1-dub>
Date: 12 Aug 2003 10:53:42 -0700
X-Trace: forums-1-dub 1060710822 172.31.143.163 (12 Aug 2003 10:53:42 -0700)
X-Original-Trace: 12 Aug 2003 10:53:42 -0700, rdomarat-pc.sybase.com
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:1575
Article PK: 3804

A cursor not open error typically means that you've performed a commit
between fetches. A commit statement will close a cursor unless you've opened
the cursor "WITH HOLD". The following SP also works fine for me BTW, which
opens the c2 cursor while c1 is still open :

create procedure MyProc ()
begin
declare c1 cursor for select table_name from systable;
declare c2 cursor for select column_name from syscolumn;
declare v1 varchar(128);
declare v2 varchar(128);
open c1;
fetch first c1 into v1;
while (sqlcode = 0 ) loop
open c2;
fetch first c2 into v2;
while (sqlcode = 0) loop
message 'c1=' || v1|| ',c2=' || v2;
fetch next c2 into v2;
end loop;
close c2;
fetch next c1 into v1;
end loop;
close c1;
end

--
Reg Domaratzki, Sybase iAnywhere Solutions
Sybase Certified Professional - Sybase ASA Developer Version 8
Please reply only to the newsgroup

iAnywhere Developer Community : http://www.ianywhere.com/developer
ASA Patches and EBFs : http://downloads.sybase.com/swx/sdmain.stm
-> Choose SQL Anywhere Studio
-> Set "Platform Preview" and "Time Frame" to ALL

<JacobT> wrote in message news:3f392711.58e2.846930886@sybase.com...
> Well, right now I'm just trouble shooting the second cursor
> and I have the second cursor declared, then I have the open
> statement, Fetch statement, followed by my commented out
> code(for debugging purposes) and then closed off by my close
> statement. but as soon as it get to the fetch statement in
> that second cursor it says cursor not open. If I comment out
> the Fetch and just go from Open to Close it gives me the
> same error. Is it a problem to have to two cursors open at
> once? My first cursor is going through my first query while
> the second cursor is going through a sub query of the first
> one.
>
>
> > What trouble are you having? An error message would go a
> > long way in trying to figure out what's wrong.
> >
> > The following procedure works great for me :
> >
> > create procedure ProcessAdmin ()
> > begin
> > DECLARE CurInsert CURSOR FOR SELECT admin_id, data FROM
> > Admin_Process WHERE row_type = 'I';
> > DECLARE CurUpdate CURSOR FOR SELECT admin_id, data FROM
> > Admin_Process WHERE row_type = 'U' ;
> > DECLARE CurDelete CURSOR FOR SELECT admin_id, data FROM
> > Admin_Process WHERE row_type = 'D';
> > DECLARE cid INTEGER;
> > DECLARE cdata VARCHAR(30);
> > OPEN CurInsert;
> > FETCH FIRST CurInsert INTO cid, cdata;
> > WHILE ( sqlcode = 0 ) LOOP
> > INSERT INTO Admin VALUES (cid,cdata,DEFAULT);
> > FETCH NEXT CurInsert INTO cid,cdata;
> > END LOOP;
> > CLOSE CurInsert;
> > OPEN CurUpdate;
> > FETCH FIRST CurUpdate INTO cid, cdata;
> > WHILE ( sqlcode = 0 ) LOOP
> > UPDATE Admin SET data = cdata WHERE admin_id = cid;
> > FETCH NEXT CurUpdate INTO cid,cdata;
> > END LOOP;
> > CLOSE CurUpdate;
> > OPEN CurDelete;
> > FETCH FIRST CurDelete INTO cid, cdata;
> > WHILE ( sqlcode = 0 ) LOOP
> > DELETE FROM Admin WHERE admin_id = cid;
> > FETCH NEXT CurDelete INTO cid,cdata;
> > END LOOP;
> > CLOSE CurDelete;
> > END;
> >
> > --
> > Reg Domaratzki, Sybase iAnywhere Solutions
> > Sybase Certified Professional - Sybase ASA Developer
> > Version 8 Please reply only to the newsgroup
> >
> > iAnywhere Developer Community :
> > http://www.ianywhere.com/developer ASA Patches and EBFs :
> > http://downloads.sybase.com/swx/sdmain.stm
> > -> Choose SQL Anywhere Studio
> > -> Set "Platform Preview" and "Time Frame" to ALL
> >
> > <JacobT> wrote in message
> > > news:3f390ef5.348f.846930886@sybase.com... I'm am trying
> > > to write a script that uses multiple cursors but for
> > > some reason I am having trouble now that I have added a
> > > second cursor. Is there some special thing that I have
> > > to do when declaring a second cursor in the same script?
> >
> >


JacobT Posted on 2003-08-12 18:10:06.0Z
Sender: 3678.3f392c5e.1804289383@sybase.com
From: JacobT
Newsgroups: ianywhere.public.general
Subject: Re: Multiple Cursor use in one batch
X-Mailer: WebNews to Mail Gateway v1.1s
Message-ID: <3f392d7e.3694.846930886@sybase.com>
References: <3f390ef5.348f.846930886@sybase.com><3f391fb3$1@forums-1-dub> <3f392711.58e2.846930886@sybase.com><3f3929a6$1@forums-1-dub>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 12 Aug 2003 11:10:06 -0700
X-Trace: forums-1-dub 1060711806 10.22.241.41 (12 Aug 2003 11:10:06 -0700)
X-Original-Trace: 12 Aug 2003 11:10:06 -0700, 10.22.241.41
Lines: 124
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:1576
Article PK: 3805

In my debugging I've gotten it down where everything works
and I'm working on this second cursor and I have everything
involving that second cursor commented out except for the
Open and Close statements just to see that it can at least
do that and it is still giving me that same error of "Cursor
is not open" and it's not the obvious problem of possibly a
typo in the cursor variable name :) So it won't even just
Open and then immediately Close it. I did that to illiminate
like what you iterated before with having a possible commit
statement closing it before it's supposed to be closed.

> A cursor not open error typically means that you've
> performed a commit between fetches. A commit statement
> will close a cursor unless you've opened the cursor "WITH
> HOLD". The following SP also works fine for me BTW, which
> opens the c2 cursor while c1 is still open :
>
> create procedure MyProc ()
> begin
> declare c1 cursor for select table_name from systable;
> declare c2 cursor for select column_name from syscolumn;
> declare v1 varchar(128);
> declare v2 varchar(128);
> open c1;
> fetch first c1 into v1;
> while (sqlcode = 0 ) loop
> open c2;
> fetch first c2 into v2;
> while (sqlcode = 0) loop
> message 'c1=' || v1|| ',c2=' || v2;
> fetch next c2 into v2;
> end loop;
> close c2;
> fetch next c1 into v1;
> end loop;
> close c1;
> end
>
> --
> Reg Domaratzki, Sybase iAnywhere Solutions
> Sybase Certified Professional - Sybase ASA Developer
> Version 8 Please reply only to the newsgroup
>
> iAnywhere Developer Community :
> http://www.ianywhere.com/developer ASA Patches and EBFs :
> http://downloads.sybase.com/swx/sdmain.stm
> -> Choose SQL Anywhere Studio
> -> Set "Platform Preview" and "Time Frame" to ALL
>
> <JacobT> wrote in message
> > news:3f392711.58e2.846930886@sybase.com... Well, right
> > now I'm just trouble shooting the second cursor and I
> > have the second cursor declared, then I have the open
> > statement, Fetch statement, followed by my commented out
> code(for debugging purposes) and then closed off by my
> > close statement. but as soon as it get to the fetch
> > statement in that second cursor it says cursor not open.
> > If I comment out the Fetch and just go from Open to
> > Close it gives me the same error. Is it a problem to
> > have to two cursors open at once? My first cursor is
> > going through my first query while the second cursor is
> > going through a sub query of the first one.
> >
> >
> > > What trouble are you having? An error message would
> > > go a long way in trying to figure out what's wrong.
> > >
> > > The following procedure works great for me :
> > >
> > > create procedure ProcessAdmin ()
> > > begin
> > > DECLARE CurInsert CURSOR FOR SELECT admin_id, data
> > > FROM Admin_Process WHERE row_type = 'I';
> > > DECLARE CurUpdate CURSOR FOR SELECT admin_id, data
> > > FROM Admin_Process WHERE row_type = 'U' ;
> > > DECLARE CurDelete CURSOR FOR SELECT admin_id, data
> > > FROM Admin_Process WHERE row_type = 'D';
> > > DECLARE cid INTEGER;
> > > DECLARE cdata VARCHAR(30);
> > > OPEN CurInsert;
> > > FETCH FIRST CurInsert INTO cid, cdata;
> > > WHILE ( sqlcode = 0 ) LOOP
> > > INSERT INTO Admin VALUES (cid,cdata,DEFAULT);
> > > FETCH NEXT CurInsert INTO cid,cdata;
> > > END LOOP;
> > > CLOSE CurInsert;
> > > OPEN CurUpdate;
> > > FETCH FIRST CurUpdate INTO cid, cdata;
> > > WHILE ( sqlcode = 0 ) LOOP
> > > UPDATE Admin SET data = cdata WHERE admin_id = cid
> > > ; FETCH NEXT CurUpdate INTO cid,cdata;
> > > END LOOP;
> > > CLOSE CurUpdate;
> > > OPEN CurDelete;
> > > FETCH FIRST CurDelete INTO cid, cdata;
> > > WHILE ( sqlcode = 0 ) LOOP
> > > DELETE FROM Admin WHERE admin_id = cid;
> > > FETCH NEXT CurDelete INTO cid,cdata;
> > > END LOOP;
> > > CLOSE CurDelete;
> > > END;
> > >
> > > --
> > > Reg Domaratzki, Sybase iAnywhere Solutions
> > > Sybase Certified Professional - Sybase ASA Developer
> > > Version 8 Please reply only to the newsgroup
> > >
> > > iAnywhere Developer Community :
> > > http://www.ianywhere.com/developer ASA Patches and
> > > EBFs : http://downloads.sybase.com/swx/sdmain.stm
> > > -> Choose SQL Anywhere Studio
> > > -> Set "Platform Preview" and "Time Frame" to ALL
> > >
> > > <JacobT> wrote in message
> > > > news:3f390ef5.348f.846930886@sybase.com... I'm am
> > > > trying to write a script that uses multiple cursors
> > > > but for some reason I am having trouble now that I
> > > > have added a second cursor. Is there some special
> > > > thing that I have to do when declaring a second
> > cursor in the same script? >
> > >
>
>


Reg Domaratzki Posted on 2003-08-12 20:39:47.0Z
From: "Reg Domaratzki" <Spam_bad_rdomarat@ianywhere.com>
Newsgroups: ianywhere.public.general
References: <3f390ef5.348f.846930886@sybase.com><3f391fb3$1@forums-1-dub> <3f392711.58e2.846930886@sybase.com><3f3929a6$1@forums-1-dub> <3f392d7e.3694.846930886@sybase.com>
Subject: Re: Multiple Cursor use in one batch
Lines: 139
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
X-Original-NNTP-Posting-Host: rdomarat-pc.sybase.com
Message-ID: <3f3950ab$1@forums-2-dub>
X-Original-Trace: 12 Aug 2003 13:40:11 -0700, rdomarat-pc.sybase.com
NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
Date: 12 Aug 2003 13:39:47 -0700
X-Trace: forums-1-dub 1060720787 10.22.241.42 (12 Aug 2003 13:39:47 -0700)
X-Original-Trace: 12 Aug 2003 13:39:47 -0700, forums-2-dub.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:1577
Article PK: 3806

We'll probably need to see your stored procedure code.

--
Reg Domaratzki, Sybase iAnywhere Solutions
Sybase Certified Professional - Sybase ASA Developer Version 8
Please reply only to the newsgroup

iAnywhere Developer Community : http://www.ianywhere.com/developer
ASA Patches and EBFs : http://downloads.sybase.com/swx/sdmain.stm
-> Choose SQL Anywhere Studio
-> Set "Platform Preview" and "Time Frame" to ALL

<JacobT> wrote in message news:3f392d7e.3694.846930886@sybase.com...
> In my debugging I've gotten it down where everything works
> and I'm working on this second cursor and I have everything
> involving that second cursor commented out except for the
> Open and Close statements just to see that it can at least
> do that and it is still giving me that same error of "Cursor
> is not open" and it's not the obvious problem of possibly a
> typo in the cursor variable name :) So it won't even just
> Open and then immediately Close it. I did that to illiminate
> like what you iterated before with having a possible commit
> statement closing it before it's supposed to be closed.
>
>
> > A cursor not open error typically means that you've
> > performed a commit between fetches. A commit statement
> > will close a cursor unless you've opened the cursor "WITH
> > HOLD". The following SP also works fine for me BTW, which
> > opens the c2 cursor while c1 is still open :
> >
> > create procedure MyProc ()
> > begin
> > declare c1 cursor for select table_name from systable;
> > declare c2 cursor for select column_name from syscolumn;
> > declare v1 varchar(128);
> > declare v2 varchar(128);
> > open c1;
> > fetch first c1 into v1;
> > while (sqlcode = 0 ) loop
> > open c2;
> > fetch first c2 into v2;
> > while (sqlcode = 0) loop
> > message 'c1=' || v1|| ',c2=' || v2;
> > fetch next c2 into v2;
> > end loop;
> > close c2;
> > fetch next c1 into v1;
> > end loop;
> > close c1;
> > end
> >
> > --
> > Reg Domaratzki, Sybase iAnywhere Solutions
> > Sybase Certified Professional - Sybase ASA Developer
> > Version 8 Please reply only to the newsgroup
> >
> > iAnywhere Developer Community :
> > http://www.ianywhere.com/developer ASA Patches and EBFs :
> > http://downloads.sybase.com/swx/sdmain.stm
> > -> Choose SQL Anywhere Studio
> > -> Set "Platform Preview" and "Time Frame" to ALL
> >
> > <JacobT> wrote in message
> > > news:3f392711.58e2.846930886@sybase.com... Well, right
> > > now I'm just trouble shooting the second cursor and I
> > > have the second cursor declared, then I have the open
> > > statement, Fetch statement, followed by my commented out
> > code(for debugging purposes) and then closed off by my
> > > close statement. but as soon as it get to the fetch
> > > statement in that second cursor it says cursor not open.
> > > If I comment out the Fetch and just go from Open to
> > > Close it gives me the same error. Is it a problem to
> > > have to two cursors open at once? My first cursor is
> > > going through my first query while the second cursor is
> > > going through a sub query of the first one.
> > >
> > >
> > > > What trouble are you having? An error message would
> > > > go a long way in trying to figure out what's wrong.
> > > >
> > > > The following procedure works great for me :
> > > >
> > > > create procedure ProcessAdmin ()
> > > > begin
> > > > DECLARE CurInsert CURSOR FOR SELECT admin_id, data
> > > > FROM Admin_Process WHERE row_type = 'I';
> > > > DECLARE CurUpdate CURSOR FOR SELECT admin_id, data
> > > > FROM Admin_Process WHERE row_type = 'U' ;
> > > > DECLARE CurDelete CURSOR FOR SELECT admin_id, data
> > > > FROM Admin_Process WHERE row_type = 'D';
> > > > DECLARE cid INTEGER;
> > > > DECLARE cdata VARCHAR(30);
> > > > OPEN CurInsert;
> > > > FETCH FIRST CurInsert INTO cid, cdata;
> > > > WHILE ( sqlcode = 0 ) LOOP
> > > > INSERT INTO Admin VALUES (cid,cdata,DEFAULT);
> > > > FETCH NEXT CurInsert INTO cid,cdata;
> > > > END LOOP;
> > > > CLOSE CurInsert;
> > > > OPEN CurUpdate;
> > > > FETCH FIRST CurUpdate INTO cid, cdata;
> > > > WHILE ( sqlcode = 0 ) LOOP
> > > > UPDATE Admin SET data = cdata WHERE admin_id = cid
> > > > ; FETCH NEXT CurUpdate INTO cid,cdata;
> > > > END LOOP;
> > > > CLOSE CurUpdate;
> > > > OPEN CurDelete;
> > > > FETCH FIRST CurDelete INTO cid, cdata;
> > > > WHILE ( sqlcode = 0 ) LOOP
> > > > DELETE FROM Admin WHERE admin_id = cid;
> > > > FETCH NEXT CurDelete INTO cid,cdata;
> > > > END LOOP;
> > > > CLOSE CurDelete;
> > > > END;
> > > >
> > > > --
> > > > Reg Domaratzki, Sybase iAnywhere Solutions
> > > > Sybase Certified Professional - Sybase ASA Developer
> > > > Version 8 Please reply only to the newsgroup
> > > >
> > > > iAnywhere Developer Community :
> > > > http://www.ianywhere.com/developer ASA Patches and
> > > > EBFs : http://downloads.sybase.com/swx/sdmain.stm
> > > > -> Choose SQL Anywhere Studio
> > > > -> Set "Platform Preview" and "Time Frame" to ALL
> > > >
> > > > <JacobT> wrote in message
> > > > > news:3f390ef5.348f.846930886@sybase.com... I'm am
> > > > > trying to write a script that uses multiple cursors
> > > > > but for some reason I am having trouble now that I
> > > > > have added a second cursor. Is there some special
> > > > > thing that I have to do when declaring a second
> > > cursor in the same script? >
> > > >
> >
> >