当前位置:网站首页>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’ ; |
边栏推荐
- Kunlunbase support for MySQL private DML syntax
- 【图像检测】基于灰度图像的积累加权边缘检测方法研究附matlab代码
- [unity, C #] character keyboard input steering and rotation
- QT基本工程的解析
- ECCV 2022 | SSP: 自支持匹配的小样本任务新思想
- Meeting OA project (V) -- meeting notice and feedback details
- sql join中on条件后接and和where
- How to synchronize when the primary and sub warehouses are modified?
- 8.穿插-从架构设计到实践理解ThreadPoolExecutor线程池
- LeetCode二叉树系列——144.二叉树的前序遍历
猜你喜欢

Std:: vector copy, append, nested access

TCP和UDP

8. Interleave - understand ThreadPoolExecutor thread pool from architecture design to practice

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

PyQt5快速开发与实战 6.6 QFormLayout(表单布局) && 6.7 嵌套布局 && 6.8 QSplitter

Basic construction of QT project

Alibaba P8 broke out this interview guide for big factories. After reading it, the salary soared by 30K!
Xiaoxiao authorization system V5.0 happy version

JVM知识点详细整理(长文警告)

VMware: use commands to update or upgrade VMware esxi hosts
随机推荐
LeetCode_ 416_ Divide equal sum subsets
浅谈安科瑞灭弧式智慧用电在养老机构的应用
AI模型风险评估 第2部分:核心内容
Conference OA project - my approval
Niuke net brush questions
什么是 Kubernetes 自定义资源定义 (CRD)?
ECCV 2022 | SSP: 自支持匹配的小样本任务新思想
基本.分块
Add: create Ou structure using PowerShell
正则表达式匹配网址
8.穿插-从架构设计到实践理解ThreadPoolExecutor线程池
Xiaoxiao authorization system V5.0 happy version
即学即用的问题解决思维,给无意识的生活装上“后视镜”
Survival analysis using rtcga clinical data
How to use grep to display file names and line numbers before matching lines
报表控件FastReport与StimulSoft功能对比
leetcode-位运算
Package Delivery(贪心)
The heavy | open atomic school source activity was officially launched
从零开始Blazor Server(3)--添加cookie授权