File: div_precision_increment_func.result

package info (click to toggle)
mariadb 1%3A11.8.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 772,520 kB
  • sloc: ansic: 2,414,714; cpp: 1,791,394; asm: 381,336; perl: 62,905; sh: 49,647; pascal: 40,897; java: 39,363; python: 20,791; yacc: 20,432; sql: 17,907; xml: 12,344; ruby: 8,544; cs: 6,542; makefile: 6,145; ada: 1,879; lex: 1,193; javascript: 996; objc: 80; tcl: 73; awk: 46; php: 22
file content (83 lines) | stat: -rw-r--r-- 2,672 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
drop table if exists t1;
## Creating new table ##
CREATE TABLE t1
(
id INT NOT NULL auto_increment,
PRIMARY KEY (id),
name VARCHAR(30),
salary INT
);
'#--------------------FN_DYNVARS_027_01-------------------------#'
## Setting initial session value of variable to 3 ##
SET @@session.div_precision_increment = 3;
## Inserting some rows in table ##
INSERT into t1(name, salary) values('Record_1', 100011);
INSERT into t1(name, salary) values('Record_2', 501);
INSERT into t1(name, salary) values('Record_3', 210);
SELECT name, salary, ((salary * 2.5)/1000) AS INCOME from t1;
name	salary	INCOME
Record_1	100011	250.0275
Record_2	501	1.2525
Record_3	210	0.5250
## Verifying variable's behavior with direct division ##
SELECT 1/7;
1/7
0.143
'#--------------------FN_DYNVARS_027_02-------------------------#'
drop table if exists t1;
## Creating new table ##
CREATE TABLE t1
(
id INT NOT NULL auto_increment,
PRIMARY KEY (id),
name VARCHAR(30),
salary INT,
income_tax FLOAT
);
connect  test_con1, localhost, root,,;
connection test_con1;
## Setting global & session scope value of variable ##
SET @@global.div_precision_increment = 2;
SET @@session.div_precision_increment = 1;
SELECT @@global.div_precision_increment;
@@global.div_precision_increment
2
SELECT @@session.div_precision_increment;
@@session.div_precision_increment
1
## Inserting some data and verifying behavior of variable ##
INSERT into t1(name, salary, income_tax) values('Record_1', 100011, 100011*2.5/1000);
INSERT into t1(name, salary, income_tax) values('Record_2', 501, 501*2.5/1000);
INSERT into t1(name, salary, income_tax) values('Record_3', 210, 210*2.5/1000);
SELECT * from t1;
id	name	salary	income_tax
1	Record_1	100011	250.027
2	Record_2	501	1.2525
3	Record_3	210	0.525
connect  test_con2, localhost, root,,;
connection test_con2;
## Verifying session & global value of variable ##
SELECT @@global.div_precision_increment = 2;
@@global.div_precision_increment = 2
1
SELECT @@session.div_precision_increment = 2;
@@session.div_precision_increment = 2
1
## Verifying behavior of variable by inserting some rows in table ##
INSERT into t1(name, salary, income_tax) values('Record_4', 100011, 100011*2.5/1000);
INSERT into t1(name, salary, income_tax) values('Record_5', 501, 501*2.5/1000);
INSERT into t1(name, salary, income_tax) values('Record_6', 210, 210*2.5/1000);
SELECT * from t1;
id	name	salary	income_tax
1	Record_1	100011	250.027
2	Record_2	501	1.2525
3	Record_3	210	0.525
4	Record_4	100011	250.027
5	Record_5	501	1.2525
6	Record_6	210	0.525
## Dropping table t1 ##
drop table t1;
disconnect test_con1;
disconnect test_con2;
connection default;
SET @@global.div_precision_increment = 4;