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.

Cursors - when is the cursor evaluated?

2 posts in General Discussion Last posting was on 2005-06-05 12:45:36.0Z
Brian Posted on 2005-06-03 15:24:09.0Z
From: "Brian" <info@infotechnics.co.uk>
Newsgroups: ianywhere.public.general
Subject: Cursors - when is the cursor evaluated?
Lines: 38
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-Original-NNTP-Posting-Host: 194-105-169-172.ifb.co.uk
Message-ID: <42a07615@forums-2-dub>
X-Original-Trace: 3 Jun 2005 08:24:05 -0700, 194-105-169-172.ifb.co.uk
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 3 Jun 2005 08:24:07 -0700, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 3 Jun 2005 08:24:09 -0700
X-Trace: forums-1-dub 1117812249 10.22.108.75 (3 Jun 2005 08:24:09 -0700)
X-Original-Trace: 3 Jun 2005 08:24:09 -0700, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4530
Article PK: 8337

Hi there

I am converting some Oracle PL/SQL to ASA. In oracle you can declare a
cursor that references a variable and the cursor gets evaluated using the
current variable value at the time the OPEN statement is issued.

e.g in oracle you can do

DECLARE
CURSOR mycur IS
SELECT aColumn
FROM aTable
WHERE an_id = v_variable;

v_variable number;
BEGIN
v_variable := 10;
OPEN mycur; // the cursor is evaluated with the value 10
...
...
CLOSE mycur;
v_variable := 20;
OPEN mycur; // the cursor is now evaluated with the value 20

END;


I previously converted some PL/SQL to SQLServer and it turned out that
SQLServer evaluated the cursor when it is declared. You need to declare it
inline then deallocate it and declare it again if you want to use the cursor
for differnet valiable values as I have above.

My question is, does ASA work like Oracle or MSS?

Thanks for any help
Brian


Breck Carter [TeamSybase] Posted on 2005-06-05 12:45:36.0Z
From: "Breck Carter [TeamSybase]" <NOSPAM__bcarter@risingroad.com>
Newsgroups: ianywhere.public.general
Subject: Re: Cursors - when is the cursor evaluated?
Organization: RisingRoad Professional Services
Reply-To: NOSPAM__bcarter@risingroad.com
Message-ID: <9us5a11onhkgrcna8v0sf9tcl52lta9vs4@4ax.com>
References: <42a07615@forums-2-dub>
X-Newsreader: Forte Agent 2.0/32.640
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Original-NNTP-Posting-Host: 208.254.244.99
X-Original-Trace: 5 Jun 2005 05:45:30 -0700, 208.254.244.99
Lines: 50
X-Original-NNTP-Posting-Host: forums-2-dub.sybase.com
X-Original-Trace: 5 Jun 2005 05:45:33 -0700, forums-2-dub.sybase.com
NNTP-Posting-Host: forums-master.sybase.com
X-Original-NNTP-Posting-Host: forums-master.sybase.com
Date: 5 Jun 2005 05:45:36 -0700
X-Trace: forums-1-dub 1117975536 10.22.108.75 (5 Jun 2005 05:45:36 -0700)
X-Original-Trace: 5 Jun 2005 05:45:36 -0700, forums-master.sybase.com
X-Authenticated-User: ngsysop
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:4533
Article PK: 8342

Like Oracle.

Breck

On 3 Jun 2005 08:24:09 -0700, "Brian" <info@infotechnics.co.uk> wrote:

>Hi there
>
>I am converting some Oracle PL/SQL to ASA. In oracle you can declare a
>cursor that references a variable and the cursor gets evaluated using the
>current variable value at the time the OPEN statement is issued.
>
>e.g in oracle you can do
>
>DECLARE
> CURSOR mycur IS
> SELECT aColumn
> FROM aTable
> WHERE an_id = v_variable;
>
> v_variable number;
>BEGIN
> v_variable := 10;
> OPEN mycur; // the cursor is evaluated with the value 10
> ...
> ...
> CLOSE mycur;
> v_variable := 20;
> OPEN mycur; // the cursor is now evaluated with the value 20
>
>END;
>
>
>I previously converted some PL/SQL to SQLServer and it turned out that
>SQLServer evaluated the cursor when it is declared. You need to declare it
>inline then deallocate it and declare it again if you want to use the cursor
>for differnet valiable values as I have above.
>
>My question is, does ASA work like Oracle or MSS?
>
>Thanks for any help
>Brian
>

--
SQL Anywhere Studio 9 Developer's Guide
Buy the book: http://www.amazon.com/exec/obidos/ASIN/1556225067/risingroad-20
bcarter@risingroad.com
RisingRoad SQL Anywhere and MobiLink Professional Services
www.risingroad.com