当前位置:网站首页>Dawei gbase8s cursor stability read esql test case
Dawei gbase8s cursor stability read esql test case
2022-07-29 10:59:00 【wangwei830】
GBase8s Cursor stability read
Basic database table creation
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);
Cursor stability reads rows
#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");
}
explain : perform cs.exe Program , Every time you press “ enter ”, The cursor of the program will point to a row of data , At this time, this row of data will be locked by sharing , Others can't modify this line of data . When the cursor points to the next row of data , The previous row of data can be modified .
testing procedure :
| result | conversation 1: | conversation 2: | window 3: |
|---|---|---|---|
| ./cs.exe | |||
| “ enter ” | |||
| onstat -g sql You can see CURSOR STABILITY Isolation level . onstat -k It can be seen that only the second 1 The line is locked , Other rows are not locked . | |||
| Lock error update Execution failure | update customer set lname=‘A1’ where fname=‘a’ ; | ||
| update Successful implementation | update customer set lname=‘B1’ where fname=‘b’ ; | ||
| “ enter ” | |||
| onstat -g sql You can see CURSOR STABILITY Isolation level . onstat -k It can be seen that only the second 2 The line is locked , Other rows are not locked . | |||
| update Successful implementation | update customer set lname=‘A2’ where fname=‘a’ ; | ||
| Lock error update Execution failure | update customer set lname=‘B2’ where fname=‘b’ ; |
边栏推荐
- LeetCode_1049_最后一块石头的重量Ⅱ
- Self collection online computer wallpaper PHP source code v2.0 adaptive end
- Qt 之自定义界面(实现无边框、可移动)
- Sunwenlong, Secretary General of the open atom open source foundation, worked together to expand open source
- 3.认识和操作一下mysql的基本命令
- Pyqt5 rapid development and practice 6.6 qformlayout & 6.7 nested layout & 6.8 qsplitter
- LeetCode二叉树系列——144.二叉树的前序遍历
- 重磅 | 开放原子校源行活动正式启动
- Software testing dry goods
- Analysis of QT basic engineering
猜你喜欢

开源峰会抢先看 | 7 月 29 日分论坛 & 活动议程速览

Watch the open source summit first | quick view of the sub Forum & Activity agenda on July 29

Pyqt5 rapid development and practice 6.6 qformlayout & 6.7 nested layout & 6.8 qsplitter

DoD 和 DoR,消减「认知偏差」的两大神器

【图像处理】基于中轴变换实现图像骨架提取附matlab代码

即学即用的问题解决思维,给无意识的生活装上“后视镜”

ECCV 2022 | ssp: a new idea of small sample tasks with self-supporting matching

幸运抽奖系统带后台源码

专访 | 阿里巴巴首席技术官程立:云 + 开源共同形成数字世界的可信基础

Detailed arrangement of JVM knowledge points (long text warning)
随机推荐
『知识集锦』一文搞懂mysql索引!!(建议收藏)
报表控件FastReport与StimulSoft功能对比
Package Delivery(贪心)
从零开始Blazor Server(3)--添加cookie授权
LeetCode_1049_最后一块石头的重量Ⅱ
开放原子开源基金会秘书长孙文龙 | 凝心聚力,共拓开源
如何使用“COPY –link”加速 Docker 构建和优化缓存
为什么应该在开发环境中使用 Kubernetes
Use R-Pack skimr to collect the beautiful display of President measurement
开源峰会抢先看 | 7月29日分论坛&活动议程速览
Learning R language these ebooks are enough!
【图像处理】基于中轴变换实现图像骨架提取附matlab代码
QT's user-defined interface (borderless and movable)
重磅 | 2022 开放原子全球开源峰会在北京开幕
GBase8s Informix Dodker 高可用集群自恢复集群启动命令oninitdb的设计与实现
Spark高效数据分析02、基础知识13篇
ES6 arrow function this points to
Spark高效数据分析01、idea开发环境搭建
浅谈安科瑞灭弧式智慧用电在养老机构的应用
Ggdag draw DAG and cause and effect diagram