Skip to content

Instantly share code, notes, and snippets.

@edgars
Created March 21, 2017 23:59
Show Gist options
  • Select an option

  • Save edgars/50ac086e7fafa601e4bffeb416b1076d to your computer and use it in GitHub Desktop.

Select an option

Save edgars/50ac086e7fafa601e4bffeb416b1076d to your computer and use it in GitHub Desktop.
@http:GET
@http:Path("/")
resource select(message m) {
sql:Parameter[] params = [];
try {
datatable dt = sql:ClientConnector.select(lcDBConnector, "select empno,ename,job,mgr,hiredate,sal,comm,deptno from emp", params);
json payload = datatables:toJson(dt);
message response = {};
messages:setJsonPayload(response, payload);
reply response;
}
catch (exception e) {
message response = {};
messages:setJsonPayload(response, responseException("select", e));
reply response;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment