CREATE TABLE IF NOT EXISTS Customers(
customerId INTEGER NOT NULL AUTO_INCREMENT,
firstName VARCHAR(300),
lastName VARCHAR(300),
registrationID INTEGER,
creditLimit DOUBLE,
country VARCHAR(300),
PRIMARY KEY (customerId)
);
Compile,
import ballerina/io;
import ballerina/sql;
import ballerinax/mysql;
import ballerinax/mysql.driver as _;
type TransactionResultCount record {
int COUNTVAL;
};
public function main() returns error? {
// Fill in MySQL DB credentials
mysql:Client dbClient = check new(user = "", password="", database = "");
int retryVal = -1;
boolean committedBlockExecuted = false;
transaction {
sql:ExecutionResult|sql:Error res = dbClient->execute("Insert into Customers (firstName,lastName,registrationID,creditLimit," +
"country) values ('James', 'Clerk', 200, 5000.75, 'USA')");
sql:ExecutionResult|sql:Error res1 = dbClient->execute("Insert into Customers (firstName,lastName,registrationID,creditLimit,country) " +
"values ('James', 'Clerk', 200, 5000.75, 'USA')");
io:println(res1);
var commitResult = commit;
if(commitResult is ()){
io:println("committedBlockExecuted");
}
io:println(res);
}
//check whether update action is performed
int count = 0;
stream<TransactionResultCount, sql:Error?> streamData = dbClient->query("Select COUNT(*) as " +
"countval from Customers where registrationID = 201");
record {|TransactionResultCount value;|}? data = check streamData.next();
io:println(data);
check dbClient.close();
}
If you extract the mainFrame class in the generated jar, you can observe "invocation$bb29$isError" is added twice.
**Affected Versions:**
Beta 2
Description: $subject
Steps to reproduce:
Setup a MySQL DB with the following table,
Compile,
type TransactionResultCount record { int COUNTVAL; };
public function main() returns error? { // Fill in MySQL DB credentials mysql:Client dbClient = check new(user = "", password="", database = ""); int retryVal = -1; boolean committedBlockExecuted = false; transaction { sql:ExecutionResult|sql:Error res = dbClient->execute("Insert into Customers (firstName,lastName,registrationID,creditLimit," + "country) values ('James', 'Clerk', 200, 5000.75, 'USA')"); sql:ExecutionResult|sql:Error res1 = dbClient->execute("Insert into Customers (firstName,lastName,registrationID,creditLimit,country) " + "values ('James', 'Clerk', 200, 5000.75, 'USA')"); io:println(res1);
}
}