1drop table if exists t1;
2drop table if exists t2;
3## Creating new table t1 ##
4CREATE TABLE t1
5(
6id INT NOT NULL auto_increment,
7PRIMARY KEY (id),
8name VARCHAR(30)
9) ENGINE = INNODB;
10## Creating another new table t2 ##
11CREATE TABLE t2
12(
13id INT NOT NULL auto_increment,
14PRIMARY KEY (id),
15name VARCHAR(30)
16) ENGINE = INNODB;
17'#--------------------FN_DYNVARS_035_01-------------------------#'
18## It should be zero ##
19SELECT @@identity = 0;
20@@identity = 0
211
22## Creating and connecting with new connection test_con1 ##
23SET @@autocommit = 0;
24## Inserting rows in table t1 ##
25INSERT into t1(name) values('Record_1');
26INSERT into t1(name) values('Record_2');
27INSERT into t1(name) values('Record_3');
28## Verifying total values in t1 ##
29SELECT @@identity from t1;
30@@identity
313
323
333
34## Now inserting some data in table t2 ##
35INSERT into t2(name) values('Record_1');
36## Verifying total values in t2 ##
37SELECT @@identity from t2;
38@@identity
391
40'#--------------------FN_DYNVARS_035_02-------------------------#'
41## Creating and connecting with new connection test_con2 ##
42SELECT * from t1;
43id	name
44## Verifying total values in t1 ##
45SELECT @@identity from t1;
46@@identity
47## Verifying total values in t2 ##
48SELECT @@identity from t2;
49@@identity
50## Inserting some more records in table t1 ##
51INSERT into t1(name) values('Record_1_1');
52INSERT into t1(name) values('Record_1_2');
53## Verifying total values in t1 ##
54SELECT @@identity from t1;
55@@identity
565
575
58## Inserting row in table t2 ##
59INSERT into t2(name) values('Record_1_3');
60## Verifying total values in t2 ##
61SELECT @@identity from t2;
62@@identity
632
64'#--------------------FN_DYNVARS_035_03-------------------------#'
65## Switching to connection test_con1 ##
66## Commiting rows added in test_con1 ##
67COMMIT;
68## Verifying records in both tables ##
69SELECT * from t1;
70id	name
711	Record_1
722	Record_2
733	Record_3
744	Record_1_1
755	Record_1_2
76SELECT * from t2;
77id	name
781	Record_1
792	Record_1_3
80## Verifying total values in t1 after commiting data ##
81SELECT @@identity from t1;
82@@identity
831
841
851
861
871
88## Verifying total values in t2 after commiting data ##
89SELECT @@identity from t2;
90@@identity
911
921
93INSERT into t1(name) values('Record_4');
94## Now verifying value of variable after inserting 1 row in this connection ##
95SELECT @@identity from t1;
96@@identity
976
986
996
1006
1016
1026
103## Dropping tables t1 & t2 ##
104drop table t1, t2;
105## Disconnecting both the connections ##
106