Subject | Re: [Firebird-Architect] Re: Cursors |
---|---|
Author | Daniel Rail |
Post date | 2004-06-06T11:16:28Z |
Hello Roman,
Saturday, June 5, 2004, 3:19:26 PM, you wrote:
DECLARE CURSOR statement. It is just a more fully implemented version
of the DECLARE CURSOR(and related commands) in FB. It is part of the
SQL standards, and surprisingly MS-SQL is pretty close to the standard.
Here's an example of how it would work, do notice FETCH ABSOLUTE,
which is not currently implemented in FB:
DECLARE myCursor SCROLL WITH RETURN CURSOR
FOR SELECT * FROM myTable
FOR UPDATE;
OPEN myCursor;
FETCH ABSOLUTE 50000 FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
CLOSE myCursor;
I can provide the SQL standard syntax if someone wants it. And, as it
stands in the standard and the other major RDBMS servers, scrollable
cursors are temporary and used with a result set.
--
Best regards,
Daniel Rail
Senior Software Developer
ACCRA Group Inc. (www.accra.ca)
ACCRA Med Software Inc. (www.filopto.com)
Saturday, June 5, 2004, 3:19:26 PM, you wrote:
>> Well, it makes sense if he includes an order by clause. But thereThey all support scrollable cursors on the "result set", by using the
>> is no way to determine the desired records in that case other than
>> determining at least the first 50,010 records. So, the
>> "first...skip" solution is as good as possible.
> I think it's not about the displaying records 50,000 to 50,010, but
> rather about scrollable cursors and operations related to them
> (first(), last(), absolute(n), etc.).
> So we are back to the discussion "Scrollable cursors: to be or not to
> be". Can anobody tell do Oracle, DB2 and MS SQL implement them and how?
DECLARE CURSOR statement. It is just a more fully implemented version
of the DECLARE CURSOR(and related commands) in FB. It is part of the
SQL standards, and surprisingly MS-SQL is pretty close to the standard.
Here's an example of how it would work, do notice FETCH ABSOLUTE,
which is not currently implemented in FB:
DECLARE myCursor SCROLL WITH RETURN CURSOR
FOR SELECT * FROM myTable
FOR UPDATE;
OPEN myCursor;
FETCH ABSOLUTE 50000 FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
FETCH NEXT FROM myCursor INTO :returnvar1, :returnvar2;
CLOSE myCursor;
I can provide the SQL standard syntax if someone wants it. And, as it
stands in the standard and the other major RDBMS servers, scrollable
cursors are temporary and used with a result set.
--
Best regards,
Daniel Rail
Senior Software Developer
ACCRA Group Inc. (www.accra.ca)
ACCRA Med Software Inc. (www.filopto.com)