当前位置:网站首页>大伟 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’ ; |
边栏推荐
- Scrape crawler framework
- Factoextra: visual PCA of multivariate statistical methods
- 美团、饿了么被杭州市监约谈要求落实食品安全管理责任 严禁恶意竞争
- Why use markdown to write?
- 若依如何实现添加水印功能
- 阿里架构师耗时一年整理的《Lucene高级文档》,吃透你也是大厂员工!
- Kunlunbase support for MySQL private DML syntax
- factoextra:多元统计的可视化
- 建议收藏丨sql行转列的一千种写法!!
- Luogu p4185 [usaco18jan]mootube g problem solution
猜你喜欢

重磅 | 基金会为白金、黄金、白银捐赠人授牌

Kunlun storage vs PostgreSQL OLTP test

学习R语言这几本电子书就够了!

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

Detailed arrangement of JVM knowledge points (long text warning)

报表控件FastReport与StimulSoft功能对比

Scrape crawler framework

重磅 | 开放原子校源行活动正式启动

DOD and Dor, two artifacts to reduce "cognitive bias"

If distributed file storage is realized according to integrated Minio
随机推荐
Achieve the effect of a menu tab
Spark高效数据分析02、基础知识13篇
One click blog building: how to use WordPress plug-in to build a dedicated blog
『知识集锦』一文搞懂mysql索引!!(建议收藏)
美团、饿了么被杭州市监约谈要求落实食品安全管理责任 严禁恶意竞争
Meeting OA project (V) -- meeting notice and feedback details
若依集成minio实现分布式文件存储
Kunlunbase support for MySQL private DML syntax
Introduction to distributed scheduling xxl-job features
JVM知识点详细整理(长文警告)
3.认识和操作一下mysql的基本命令
Basic construction of QT project
Steps of project explanation in interview
Review of the 16th issue of HMS core discovery | play with the new "sound" state of AI with tiger pier
sql join中on条件后接and和where
What are the compensation standards for hospital misdiagnosis? How much can the hospital pay?
Pyqt5 rapid development and practice 6.6 qformlayout & 6.7 nested layout & 6.8 qsplitter
Hugo NexT V4 介绍
从零开始Blazor Server(3)--添加cookie授权
Luogu p4185 [usaco18jan]mootube g problem solution