Results 1 to 2 of 2
  1. #1
    Join Date
    May 2012

    Unanswered: when to use with as, when to use declare cursor for

    Hallo everyone,

    I understand how DB2 internally operates with as and declare cursor for. As in the documentation stated:
    1. with as is aiming the pre-select operation before the usually bigger select statment.
    2. declare cursor for -> a real table stored temporarily. Often used to load statement.

    So far so good. I am wondering what the real differences between the two, because I can make use of them vise and versa for my sql codes.

    Thank you.


  2. #2
    Join Date
    Jan 2003
    Provided Answers: 5
    WITH-AS is a Common Table Expression (CTE) and is part of a select-statement. It can be used anywhere. A Cursor is a device for accessing the results of a query. DB2 may create one for a select statement internally. You can declare one if you wish to process the results set with SQL, for example.


Posting Permissions

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