View previous topic :: View next topic
|
Author |
Message |
cvishu
Active User
Joined: 31 Jul 2007 Posts: 136 Location: india
|
|
|
|
Hi ,
I came across a query that looks something like below , but i dont know the actual purpose of this , can anyone please explain .
EXEC SQL
DECLARE xxxxxx CURSOR
WITH RETURN
FOR
SELECT -1
FROM SYSIBM.SYSDUMMY1
END-EXEC. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Without more information, no one here will know the purpose of this query or why it is within a cursor.
The SELECT will return a -1. . . |
|
Back to top |
|
|
cvishu
Active User
Joined: 31 Jul 2007 Posts: 136 Location: india
|
|
|
|
dick scherrer wrote: |
Hello,
Without more information, no one here will know the purpose of this query or why it is within a cursor.
The SELECT will return a -1. . . |
sorry i myself don't know the query , some one sent me the question and i posted , the person was more interested in what will that with return option do , followed by a -1.
i will see if i can get more info from the person |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
"with return" is used in stored procedures to create result sets.
for a more detailed answer, start reading about stored procedures and result sets. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
One of my clients insists that every query used in MS-SqlServer be placed in a stored procedure. I've not run into this on the mainframe, but it seems to be somewhat common with SqlServer. Might this be the case here also?
I'm probably missing something, but i'm not clear on why the cursor or the "with return".
I suspect there is more not posted code that does this selectively. . . |
|
Back to top |
|
|
avik1983
New User
Joined: 11 Mar 2010 Posts: 5 Location: Chennai
|
|
|
|
I hope this is a pure existence check without any condition writen . So it should always return -1
The output row count will be always 1, so i couldn't understand the usage of cursor. |
|
Back to top |
|
|
|