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.

Fetch

2 posts in General Discussion Last posting was on 2003-08-13 14:24:50.0Z
JacobT Posted on 2003-08-13 13:56:08.0Z
Sender: 4405.3f3a4243.1804289383@sybase.com
From: JacobT
Newsgroups: ianywhere.public.general
Subject: Fetch
X-Mailer: WebNews to Mail Gateway v1.1s
Message-ID: <3f3a4378.4412.846930886@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 13 Aug 2003 06:56:08 -0700
X-Trace: forums-1-dub 1060782968 10.22.241.41 (13 Aug 2003 06:56:08 -0700)
X-Original-Trace: 13 Aug 2003 06:56:08 -0700, 10.22.241.41
Lines: 27
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:1586
Article PK: 3814

Below is a sample of some code I've written. I am getting an
error in the second Fetch statement of "Wrong number of
variables in FETCH". What am I missing here? From what I can
tell I have declared my cursor variable correctly and it
seems to be a pretty straight forward Fetch but yet it's
giving me that error. Any suggestions?


DECLARE @ThisResult char(254)
DECLARE @ThisResult2 char(254)
DECLARE c CURSOR FOR SELECT Invoice FROM Database.filename
Group by Invoice Having Count(Invoice) > 1
DECLARE c2 CURSOR FOR SELECT * INTO #Results FROM
database.filename as ar WHERE ar.Invoice = @ThisResult

Open c
Fetch c INTO @ThisResult

While (@@Fetch_Status=0) Begin
Select @abc = @abc + 1

Open c2
FETCH c2 INTO @ThisResult2 --Error hear

-----Code here-----

Close c2


"Bruce Hay" Posted on 2003-08-13 14:24:50.0Z
From: "Bruce Hay" <hay at sybase dot com>
Newsgroups: ianywhere.public.general
References: <3f3a4378.4412.846930886@sybase.com>
Subject: Re: Fetch
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: hay-xp.sybase.com
X-Original-NNTP-Posting-Host: hay-xp.sybase.com
Message-ID: <3f3a4a32$1@forums-1-dub>
Date: 13 Aug 2003 07:24:50 -0700
X-Trace: forums-1-dub 1060784690 172.31.142.57 (13 Aug 2003 07:24:50 -0700)
X-Original-Trace: 13 Aug 2003 07:24:50 -0700, hay-xp.sybase.com
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:1587
Article PK: 3817

The "SELECT * INTO #Results" statement doesn't generate a result set; it
creates and populates a temporary table. Thus it doesn't belong in a cursor
declaration. If you really want to fetch the results, remove the "INTO
#Results".

Whitepapers, TechDocs, bug fixes are all available through the iAnywhere
Developer Community at http://www.ianywhere.com/developer

<JacobT> wrote in message news:3f3a4378.4412.846930886@sybase.com...
> Below is a sample of some code I've written. I am getting an
> error in the second Fetch statement of "Wrong number of
> variables in FETCH". What am I missing here? From what I can
> tell I have declared my cursor variable correctly and it
> seems to be a pretty straight forward Fetch but yet it's
> giving me that error. Any suggestions?
>
>
> DECLARE @ThisResult char(254)
> DECLARE @ThisResult2 char(254)
> DECLARE c CURSOR FOR SELECT Invoice FROM Database.filename
> Group by Invoice Having Count(Invoice) > 1
> DECLARE c2 CURSOR FOR SELECT * INTO #Results FROM
> database.filename as ar WHERE ar.Invoice = @ThisResult
>
> Open c
> Fetch c INTO @ThisResult
>
> While (@@Fetch_Status=0) Begin
> Select @abc = @abc + 1
>
> Open c2
> FETCH c2 INTO @ThisResult2 --Error hear
>
> -----Code here-----
>
> Close c2