From d72d9d3e5c22ab439ef865427946019d9763c39f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=81=E7=AB=A0=E5=BD=AC?= <2629351295@qq.com> Date: Tue, 20 Sep 2022 11:59:08 +0000 Subject: [PATCH] =?UTF-8?q?=E7=AC=94=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 翁章彬 <2629351295@qq.com> --- .../2022-09-20 \346\270\270\346\240\207.md" | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 "01\347\277\201\347\253\240\345\275\254/\347\254\224\350\256\260/2022-09-20 \346\270\270\346\240\207.md" diff --git "a/01\347\277\201\347\253\240\345\275\254/\347\254\224\350\256\260/2022-09-20 \346\270\270\346\240\207.md" "b/01\347\277\201\347\253\240\345\275\254/\347\254\224\350\256\260/2022-09-20 \346\270\270\346\240\207.md" new file mode 100644 index 0000000..b706401 --- /dev/null +++ "b/01\347\277\201\347\253\240\345\275\254/\347\254\224\350\256\260/2022-09-20 \346\270\270\346\240\207.md" @@ -0,0 +1,59 @@ +# 游标 + +## 创建游标 + +declare 游标名 cursor [scroll] for (表) + +## 打开游标 + +open 游标名 + +## 关闭游标 + +close 游标名 + +## 删除游标 + +deallocate 游标名 + +# 提取数据 + +## 第一行 + +fetch **first** from 游标名 + +## 最后一行 + +fetch **last** from 游标名 + +## 第n行 + +fetch **absolute** n from 游标名 + +## 当前位置第n行 + +fetch **relative** n from 游标名 + +## 当前位置下一行 + +fetch **next** from 游标名 + +## 当前位置的上一行 + +fetch **prior** from 游标名 + +# 游标指向某行多列数据 + +declare 游标名 cursor [scroll] for (select 列1,列2,列3,列4 from 表名) + +把数据赋给变量 + +fetch **first** from 游标名 into 变量1,变量2,变量3,变量4 + +# @@FETCH_STATUS + +@@FETCH_STATUS=0,提取成功 + +@@FETCH_STATUS=-1,提取失败 + +@@FETCH_STATUS=-2,行不存在 \ No newline at end of file -- Gitee