Guest User

Untitled

a guest
Aug 11th, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. import ballerina/io;
  2. import ballerina/jdbc;
  3. import ballerina/sql;
  4.  
  5. public type EmployeeOracle record {
  6. string first_name,
  7. string last_name,
  8. float id,
  9. float salary,
  10. };
  11.  
  12. endpoint jdbc:Client testDB {
  13. url: "jdbc:oracle:thin:@localhost:49161:xe",
  14. username: "system",
  15. password: "oracle",
  16. poolOptions: { maximumPoolSize: 1 }
  17. };
  18.  
  19. function main(string... args) {
  20. _ = getInfoById(1);
  21. }
  22.  
  23. function getInfoById(int id) {
  24. sql:Parameter para1 = { sqlType: sql:TYPE_REFCURSOR, direction: sql:DIRECTION_OUT, recordType: EmployeeOracle };
  25. sql:Parameter para2 = { sqlType: sql:TYPE_INTEGER, value: id };
  26.  
  27. var ret = testDB->call("{call get_info_by_id(?, ?)}", [EmployeeOracle], para1, para2);
  28.  
  29. table<EmployeeOracle> dt = check <table>para1.value;
  30.  
  31. foreach entry in dt {
  32. io:println(entry.id + "|" + entry.first_name + "|" + entry.last_name + "|" + entry.salary);
  33. }
  34. }
Add Comment
Please, Sign In to add comment