使用游標更改資料

2022-06-03 10:54:07 字數 659 閱讀 4224

ado、ole db 和 odbc 應用程式介面 (api) 支援對結果集內應用程式所處的當前行進行更新。其基本過程如下:

將結果集的各列繫結到程式變數上。

執行查詢。

執行 api 函式或方法,將應用程式定位在結果集的某一行上。

使用要更新的列的新資料值填充繫結的程式變數。

執行以下函式或方法之一插入行:recordsetupdateirowsetchangesetdatasqlsetpos

table_name。而不影響其它參與該游標的表。

use northwind

godeclare abc cursor for

select companyname from shippers

open abc

gofetch next from abc

goupdate shippers set companyname = n'speedy express, inc.' where current of abc

goclose abc

deallocate abc

go

使用游標 引數游標

參游標是指帶有引數的游標。在定義了引數游標之後,當使用不同引數值多次開啟游標時,可以生成不同的結果集。定義引數游標的語法如下 cursor cursor name parameter name datetype is select statement 注意,當定義引數游標時,游標引數只能指定資料型別...

使用游標 游標FOR迴圈

游標for迴圈是在pl sql塊中使用游標最簡單的方式,它簡化了對游標的處理。當使用游標for迴圈時,oracle會隱含的開啟游標,提取游標資料並關閉游標。例子 顯示emp表所有雇員名及其工資 declare cursor emp cursor isselect ename,sal from emp...

Oracle使用游標更新資料

使用游標修改資料 定義乙個游標,游標名稱為 mycursor 更新scott使用者中emp表中empno為7369的銷售額 created on 2015 11 30 by zhanw declare he emp rowtype cursor mycursor pid integer is sel...