Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ballerina/io;
- import ballerina/jdbc;
- import ballerina/sql;
- public type EmployeeOracle record {
- string first_name,
- string last_name,
- float id,
- float salary,
- };
- endpoint jdbc:Client testDB {
- url: "jdbc:oracle:thin:@localhost:49161:xe",
- username: "system",
- password: "oracle",
- poolOptions: { maximumPoolSize: 1 }
- };
- function main(string... args) {
- _ = getInfoById(1);
- }
- function getInfoById(int id) {
- sql:Parameter para1 = { sqlType: sql:TYPE_REFCURSOR, direction: sql:DIRECTION_OUT, recordType: EmployeeOracle };
- sql:Parameter para2 = { sqlType: sql:TYPE_INTEGER, value: id };
- var ret = testDB->call("{call get_info_by_id(?, ?)}", [EmployeeOracle], para1, para2);
- table<EmployeeOracle> dt = check <table>para1.value;
- foreach entry in dt {
- io:println(entry.id + "|" + entry.first_name + "|" + entry.last_name + "|" + entry.salary);
- }
- }
Add Comment
Please, Sign In to add comment