当前位置:网站首页>大伟 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’ ; |
边栏推荐
- Survival analysis using rtcga clinical data
- JVM知识点详细整理(长文警告)
- GPO: using PowerShell scripts in start/logon
- VMware: use commands to update or upgrade VMware esxi hosts
- sql join中on条件后接and和where
- Using xgboost with tidymodels
- Matplotlib Chinese question
- Less than 10% of the 3 software test interview questions can be answered correctly! How many do you know?
- 建议收藏丨sql行转列的一千种写法!!
- Detailed arrangement of JVM knowledge points (long text warning)
猜你喜欢

VMware: use commands to update or upgrade VMware esxi hosts

站点数据收集-Scrapy使用笔记

Site data collection -scrapy usage notes

8.穿插-从架构设计到实践理解ThreadPoolExecutor线程池

The heavyweight foundation awarded platinum, gold and silver donors

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

Review of the 16th issue of HMS core discovery | play with the new "sound" state of AI with tiger pier

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

Detailed arrangement of JVM knowledge points (long text warning)

Pytorch 入门
随机推荐
Error: Protobuf syntax version should be first thing in file
Kunlunbase instruction manual (III) data import & synchronization
How to synchronize when the primary and sub warehouses are modified?
Use R-Pack skimr to collect the beautiful display of President measurement
报表控件FastReport与StimulSoft功能对比
How can agile development reduce cognitive bias in collaboration| Agile way
重磅 | 2022 开放原子全球开源峰会在北京开幕
阿里P8爆出的这份大厂面试指南,看完工资暴涨30k!
DOD and Dor, two artifacts to reduce "cognitive bias"
LeetCode二叉树系列——144.二叉树的前序遍历
Ggdag draw DAG and cause and effect diagram
聊聊性能测试环境搭建
Drawing box and ellipse of WPF screenshot control (IV) "imitating wechat"
LeetCode_ 416_ Divide equal sum subsets
A tour of grp:04 - GRP unary call unary call
LeetCode_416_分割等和子集
Using xgboost with tidymodels
Alibaba P8 broke out this interview guide for big factories. After reading it, the salary soared by 30K!
使用tidymodels搞定二分类logistic模型
Roots of equations in R language dichotomy and Newton iteration