Declare Cursor question again

Started by Dr. Michael Meskesover 27 years ago5 messages
#1Dr. Michael Meskes
meskes@online-club.de

Is the following legal:

if (<condition>) {
exec sql declare cur cursor for
select name, nr from table where nr < 10;
}
else {
exec sql declare cur cursor for
select name, nr from table where nr >= 10;
}

That is declaring one cursor in two different ways? Oracle cannot do that.
We can, though. Shall I disable this (and remove my last changes) or is this
a good feature (as I think it is) and we keep it? Only disadvantage is that
the declare tarnslates into a C statement and is not really a declaration
anymore.

Michael
--
Dr. Michael Meskes meskes@online-club.de, meskes@debian.org
Go SF49ers! Go Rhein Fire! Use Debian GNU/Linux!

#2Thomas G. Lockhart
lockhart@alumni.caltech.edu
In reply to: Dr. Michael Meskes (#1)
Re: [HACKERS] Declare Cursor question again

Shall I disable this (and remove my last changes) or is this
a good feature (as I think it is) and we keep it? Only disadvantage is
that the declare tarnslates into a C statement and is not really a
declaration anymore.

On my Ingres box, the "declare cursor" statements could appear up in or
near the declarations portion of the program or routine. Wouldn't
associating this statement with executable code put limitations on
statement location which other systems (and perhaps the standard) do not
see?

- Tom

#3Andreas Zeugswetter
andreas.zeugswetter@telecom.at
In reply to: Thomas G. Lockhart (#2)
AW: [HACKERS] Declare Cursor question again

Is the following legal:
if (<condition>) {
exec sql declare cur cursor for
select name, nr from table where nr < 10;
}
else {
exec sql declare cur cursor for
select name, nr from table where nr >= 10;
}

That is declaring one cursor in two different ways? Oracle cannot do that.
We can, though. Shall I disable this (and remove my last changes) or is this
a good feature (as I think it is) and we keep it? Only disadvantage is that
the declare tarnslates into a C statement and is not really a declaration
anymore.

Informix can't eighter:
informix@zeus:/usr/informix> esql hallo.ec
esqlc: "hallo.ec", line 9: Error -33055: The name cur has already been used.
1 error(s) found

I guess the objective has to be: be fast during execution
and therefore a declare is probably better.

Andreas

#4Dr. Michael Meskes
meskes@online-club.de
In reply to: Thomas G. Lockhart (#2)
Re: [HACKERS] Declare Cursor question again

On Thu, Aug 06, 1998 at 06:17:18AM +0000, Thomas G. Lockhart wrote:

On my Ingres box, the "declare cursor" statements could appear up in or
near the declarations portion of the program or routine. Wouldn't
associating this statement with executable code put limitations on
statement location which other systems (and perhaps the standard) do not
see?

Yes. In Oracle you can put it outside a function.

Michael
--
Dr. Michael Meskes meskes@online-club.de, meskes@debian.org
Go SF49ers! Go Rhein Fire! Use Debian GNU/Linux!

#5Dr. Michael Meskes
meskes@online-club.de
In reply to: Andreas Zeugswetter (#3)
Re: [HACKERS] Declare Cursor question again

On Thu, Aug 06, 1998 at 10:52:48AM +0200, Andreas Zeugswetter wrote:

Informix can't eighter:
informix@zeus:/usr/informix> esql hallo.ec
esqlc: "hallo.ec", line 9: Error -33055: The name cur has already been used.
1 error(s) found

I guess the objective has to be: be fast during execution
and therefore a declare is probably better.

It doesn't make much of a speed difference. But my solution is not needed.
That's what prepare is for.

Michael
--
Dr. Michael Meskes meskes@online-club.de, meskes@debian.org
Go SF49ers! Go Rhein Fire! Use Debian GNU/Linux!