Results 1 to 6 of 6

Thread: Cursors

  1. #1
    Join Date
    Feb 2002
    Location
    Minneapolis, MN
    Posts
    253

    Unanswered: Cursors

    Does anyone know of any good place to find examples of cursors? I have looked in both the Application Programming reference and SQL Reference and have found really nothing....

    Thanks!
    Anthony Robinson

    "If I'm curt with you, it's because time is a factor here. I think fast, I talk fast, and I need you guys to act fast if you want to get out of this. So, pretty please - with sugar on top..."

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    What are you looking for in particular?

    Andy

  3. #3
    Join Date
    Feb 2002
    Location
    Minneapolis, MN
    Posts
    253
    Need to select individual values from a table, evaluate them, and then display them.

    In SQL Server it was kind of like:
    DELCARE CURSOR FOR SELECT........

    FETCH VALUE
    DO SOMETHING TO IT
    WHILE @@FETCHSTATUS=1 (or something, meaning more to get)
    FETCH THE NEXT ONE
    CLOSE CURSOR
    DEALLOCATE CURSOR

    I've really only done really basic stuff with cursors in DB2 (in stored procedures for returning a result set).

    Again, any suggestions would be appreciated.
    Anthony Robinson

    "If I'm curt with you, it's because time is a factor here. I think fast, I talk fast, and I need you guys to act fast if you want to get out of this. So, pretty please - with sugar on top..."

  4. #4
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    For DB2 Linux, UNIX, and Windows version 8, look in the SQL Reference Vol 2 for the following SQL statements:

    delcare cursor
    open cursor
    fetch
    update (where currrent of cursor)
    delete (where current of cursor)
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  5. #5
    Join Date
    Feb 2002
    Location
    Minneapolis, MN
    Posts
    253
    I only have access to te version 7 books, and there isn't a whole lot there. Just says this is DECLARE CURSOR <name>...no real examples

    Checked SQL Cookbook, too...
    Anthony Robinson

    "If I'm curt with you, it's because time is a factor here. I think fast, I talk fast, and I need you guys to act fast if you want to get out of this. So, pretty please - with sugar on top..."

  6. #6
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    You can download all DB2 manuals from the IBM website. See useful DB2 stuff. The ones in PDF format are searchable (if you have the correct version of Acrobat reader that is free) and they also have PDF hotlinks. I would downlload the entire directory of manuals using a ftp program.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •