游标使用步骤:

  1. 定义游标:

    DECLARE CURSOR CURSOR_NAME FOR SELECT ...

  2. 打开游标:

    OPEN CURSOR_NAME

  3. 提取数据:

    FETCH CURSOR_NAME INTO ...

  4. 关闭游标:

    CLOSE CURSOR_NAME