当前位置:网站首页>大伟 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’ ; |
边栏推荐
- Mitsubishi PLC and Siemens PLC
- LeetCode_416_分割等和子集
- Use tidymodels to solve the binary logistic model
- How can agile development reduce cognitive bias in collaboration| Agile way
- R language Monte Carlo method and average method are used to calculate the definite integral. Considering the random point casting method, the confidence is 0.05, and the requirement is ϵ= 0.01, numbe
- Luogu p1816 loyalty solution
- sql join中on条件后接and和where
- GPO:在 Start/Logon 中使用 PowerShell 脚本
- Detailed arrangement of JVM knowledge points (long text warning)
- Kunlunbase instruction manual (II) best practices for peer-to-peer deployment
猜你喜欢
Summer 2022 software innovation laboratory training JDBC
数据可视化设计指南(信息图表篇)
Sunwenlong, Secretary General of the open atom open source foundation, worked together to expand open source
专访 | 阿里巴巴首席技术官程立:云 + 开源共同形成数字世界的可信基础
leetcode-位运算
Factoextra: visual PCA of multivariate statistical methods
重磅 | 开放原子校源行活动正式启动
WPF 截图控件之绘制方框与椭圆(四) 「仿微信」
Basic construction of QT project
If distributed file storage is realized according to integrated Minio
随机推荐
Regular expression matching URL
LeetCode_ 278_ First wrong version
R language uses data set veteran for survival analysis
LeetCode_1049_最后一块石头的重量Ⅱ
98. (cesium chapter) cesium point heat
ES6 arrow function this points to
Using Riemann sum to calculate approximate integral in R language
使用R包skimr汇总统计量的优美展示
Getting started with pytoch
Analysis of QT basic engineering
Learning R language these ebooks are enough!
「PHP基础知识」使用数组保存数据
使用R包PreMSIm根据基因表达量来预测微卫星不稳定
使用tidymodels搞定二分类logistic模型
WPF 截图控件之绘制方框与椭圆(四) 「仿微信」
PyQt5快速开发与实战 6.6 QFormLayout(表单布局) && 6.7 嵌套布局 && 6.8 QSplitter
『面试知识集锦100篇』1.面试技巧篇丨HR的小心思,你真的懂吗?
Pytorch 入门
Discussion on the application of arcing smart electricity in elderly care institutions
If distributed file storage is realized according to integrated Minio