当前位置:网站首页>大伟 GBase8s游标稳定性读ESQL测试用例
大伟 GBase8s游标稳定性读ESQL测试用例
2022-07-29 10:52:00 【wangwei830】
GBase8s游标稳定性读
基础库表建立
create database db03 with log;
create table customer(
fname char(9),
lname char(9)
);
insert into customer values('a','A');
insert into customer values('b','B');
insert into customer values('c','C');
insert into customer values('aa','AA');
insert into customer values('bb','BB');
alter table customer lock mode (row);
游标稳定性读取行
#include <stdio.h>
#include <unistd.h>
EXEC SQL define FNAME_LEN 15;
EXEC SQL define LNAME_LEN 15;
main()
{
EXEC SQL BEGIN DECLARE SECTION;
char fname[ FNAME_LEN + 1 ];
char lname[ LNAME_LEN + 1 ];
EXEC SQL END DECLARE SECTION;
printf( "DEMO1 Sample ESQL Program running.\n\n");
EXEC SQL WHENEVER ERROR STOP;
EXEC SQL connect to 'db03';
EXEC SQL DECLARE democursor cursor for
select fname, lname
into :fname, :lname
from customer
where lname < 'C' ;
EXEC SQL execute immediate 'BEGIN WORK';
EXEC SQL execute immediate 'SET ISOLATION TO CURSOR STABILITY';
EXEC SQL open democursor;
for (;;)
{
getchar();
EXEC SQL fetch democursor;
if (strncmp(SQLSTATE, "00", 2) != 0)
break;
printf("%s %s\n",fname, lname);
}
if (strncmp(SQLSTATE, "02", 2) != 0)
printf("SQLSTATE after fetch is %s\n", SQLSTATE);
EXEC SQL execute immediate 'COMMIT WORK';
EXEC SQL close democursor;
EXEC SQL free democursor;
EXEC SQL disconnect current;
printf("\nDEMO1 Sample Program over.\n\n");
}
说明: 执行cs.exe程序,每按一次“回车”,程序的游标就会指向一行数据,此时这行数据就会被加上共享锁,别人就不能修改这行数据了。当游标指向下一行数据时,前面的一行数据就可以修改了。
测试步骤:
| 结果 | 会话1: | 会话2: | 窗口3: |
|---|---|---|---|
| ./cs.exe | |||
| “回车” | |||
| onstat -g sql 可以看到CURSOR STABILITY隔离级别。 onstat -k 可以看到只有第1行锁定了,其他行没有锁定。 | |||
| 锁报错update执行失败 | update customer set lname=‘A1’ where fname=‘a’ ; | ||
| update执行成功 | update customer set lname=‘B1’ where fname=‘b’ ; | ||
| “回车” | |||
| onstat -g sql 可以看到CURSOR STABILITY隔离级别。 onstat -k 可以看到只有第2行锁定了,其他行没有锁定。 | |||
| update执行成功 | update customer set lname=‘A2’ where fname=‘a’ ; | ||
| 锁报错update执行失败 | update customer set lname=‘B2’ where fname=‘b’ ; |
边栏推荐
- 专访 | 阿里巴巴首席技术官程立:云 + 开源共同形成数字世界的可信基础
- Pyqt5 rapid development and practice 6.6 qformlayout & 6.7 nested layout & 6.8 qsplitter
- Hugo NexT V4 介绍
- Regular expression matching URL
- 会议OA项目(五)---- 会议通知、反馈详情
- LeetCode二叉树系列——144.二叉树的前序遍历
- Use tidymodels to solve the binary logistic model
- [unity, C #] character keyboard input steering and rotation
- 基于STM32设计的酒驾报警系统
- A tour of grp:04 - GRP unary call unary call
猜你喜欢

Data visualization design guide (information chart)

QT工程基本构建

重磅 | 2022 开放原子全球开源峰会在北京开幕

Kunlunbase instruction manual (I) quick installation manual

QT基本工程的解析

R 语言 用黎曼和求近似 积分

Understand what a binary tree is (types, traversal methods, definitions of binary trees)

ES6 arrow function this points to

If distributed file storage is realized according to integrated Minio

主子仓库都修改,如何进行同步?
随机推荐
Learning R language these ebooks are enough!
正则表达式匹配网址
主子仓库都修改,如何进行同步?
深度强化学习应用实践技巧
LeetCode二叉树系列——144.二叉树的前序遍历
开源峰会抢先看 | 7月29日分论坛&活动议程速览
R package pedquant realizes stock download and financial quantitative analysis
Error: Protobuf syntax version should be first thing in file
Zhou Hongyi: 360 is the largest secure big data company in the world
js两个数组对象进行合并去重
Pytorch 入门
Error: Protobuf syntax version should be first thing in file
Matplotlib Chinese question
2022cuda summer training camp Day2 practice
JVM知识点详细整理(长文警告)
2.安装MySQL
AI模型风险评估 第2部分:核心内容
leetcode-位运算
Svn revision keyword
How to synchronize when the primary and sub warehouses are modified?