<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Manuri Amaya Perera on Medium]]></title>
        <description><![CDATA[Stories by Manuri Amaya Perera on Medium]]></description>
        <link>https://medium.com/@Manuri?source=rss-2b16995fc97------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*P0SoIT8Yfv2CmwkZz0I0tw.jpeg</url>
            <title>Stories by Manuri Amaya Perera on Medium</title>
            <link>https://medium.com/@Manuri?source=rss-2b16995fc97------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 13 Nov 2026 01:46:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Manuri/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Interact with an Oracle database with Ballerina]]></title>
            <link>https://medium.com/ballerina-techblog/interact-with-an-oracle-database-with-ballerina-ed84052713e8?source=rss-2b16995fc97------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed84052713e8</guid>
            <category><![CDATA[jdbc]]></category>
            <category><![CDATA[ballerina]]></category>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[ballerinalang]]></category>
            <dc:creator><![CDATA[Manuri Amaya Perera]]></dc:creator>
            <pubDate>Wed, 20 Mar 2019 08:44:13 GMT</pubDate>
            <atom:updated>2019-03-20T09:14:12.769Z</atom:updated>
            <content:encoded><![CDATA[<p>The title pretty much explains the purpose! So, I’m moving on to the sample. We are using <em>ballerinax/jdbc</em> package here.</p><p>Ballerina version: 0.990.3<br>Oracle database version used: Oracle-xe-11g</p><p><strong><em>Note: </em></strong><em>You need to copy the Oracle JDBC driver jar into $BALLERINA_HOME/bre/lib</em></p><p>Table creation query:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e468de93536e38577d31049e32a1f7a/href">https://medium.com/media/8e468de93536e38577d31049e32a1f7a/href</a></iframe><p>Sample:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82dbf57f4c68c7515559c6165ae8a971/href">https://medium.com/media/82dbf57f4c68c7515559c6165ae8a971/href</a></iframe><p>How to run:</p><p><em>ballerina run oracle-0.990.3.bal</em></p><p>Output:</p><p><em>1.0|Harry|Potter|1000.0<br>2.0|Ron|Weasley|1000.0</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed84052713e8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ballerina-techblog/interact-with-an-oracle-database-with-ballerina-ed84052713e8">Interact with an Oracle database with Ballerina</a> was originally published in <a href="https://medium.com/ballerina-techblog">Ballerina Swan Lake Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Containerized Ballerina service with a MongoDB data backend]]></title>
            <link>https://medium.com/ballerina-techblog/containerized-ballerina-service-with-a-mongodb-data-backend-c5c0a867720e?source=rss-2b16995fc97------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5c0a867720e</guid>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[ballerinalang]]></category>
            <dc:creator><![CDATA[Manuri Amaya Perera]]></dc:creator>
            <pubDate>Sun, 25 Nov 2018 15:09:07 GMT</pubDate>
            <atom:updated>2019-02-13T06:24:41.469Z</atom:updated>
            <content:encoded><![CDATA[<p>WSO2 provides a <a href="https://github.com/wso2-ballerina/module-mongodb/releases">ballerina module </a>for MongoDB. This module requires manual installation (i.e. This is not available on Ballerina central). To perform the manual installation, an installation script is available. If you are creating a containerized Ballerina service which uses this module, it is not possible through the default <a href="https://hub.docker.com/r/ballerina/ballerina/">Ballerina image</a>, due to this manual installation requirement.</p><p>So, here’s a sample for you to create a Docker image with MongoDB module installed.</p><p>Dockerfile:</p><p>Please replace the versions as required.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bf62b4fc16b2f561cd935c782f56c922/href">https://medium.com/media/bf62b4fc16b2f561cd935c782f56c922/href</a></iframe><p>Docker image build command:</p><p><em>docker build -t mongodb-ballerina .</em></p><p>Once built when you execute <em>docker images </em>command you should be able to see the image named <em>mongodb-ballerina.</em></p><p>You can find a Balleria program below which uses the image we just built in order to create a containerized service that uses MongoDB module.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5040833c7d741ba46c43f30fdcfca4a4/href">https://medium.com/media/5040833c7d741ba46c43f30fdcfca4a4/href</a></iframe><p>Command to build the Ballerina program</p><p><em>ballerina build mongodb-service-docker.bal</em></p><p>Once you build an image will be created which encapsulates the service, on top of the mongodb-ballerina image we created. Also you will be presented with the docker command similar to below, to create a container and run.</p><p><em>docker run -d -p 9090:9090 ballerina.guides.io/ballerina_mongodb_service:v1.0</em></p><p>Sample request:</p><p><em>curl -v </em><a href="http://localhost:9090/dummyService/getData"><em>http://localhost:9090/dummyService/getData</em></a></p><p>That’s about it! Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5c0a867720e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ballerina-techblog/containerized-ballerina-service-with-a-mongodb-data-backend-c5c0a867720e">Containerized Ballerina service with a MongoDB data backend</a> was originally published in <a href="https://medium.com/ballerina-techblog">Ballerina Swan Lake Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s connect to MongoDB Atlas with Ballerina]]></title>
            <link>https://medium.com/ballerina-techblog/lets-connect-to-mongodb-atlas-with-ballerina-8fd46f168fb6?source=rss-2b16995fc97------2</link>
            <guid isPermaLink="false">https://medium.com/p/8fd46f168fb6</guid>
            <category><![CDATA[wso2]]></category>
            <category><![CDATA[ballerinalang]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Manuri Amaya Perera]]></dc:creator>
            <pubDate>Fri, 02 Nov 2018 16:27:47 GMT</pubDate>
            <atom:updated>2019-02-13T06:24:34.164Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to connect to MongoDB Atlas with Ballerina</h3><p>Ballerina is a programming language designed to fill the gap between integration focused products and general purpose programming languages. Read more <a href="https://ballerina.io/">here</a>. MongoDB Atlas is a fully managed cloud database service developed by the MongoDB folks. Lets see how to connect to MongoDB Atlas cluster and perform some operations, using MongoDB package provided by WSO2.</p><ol><li>First install Ballerina! I used Ballerina 0.982.0 version. You can download the installer from <a href="https://ballerina.io/downloads/">here</a>.</li></ol><p>2. Then download MongoDB package from <a href="https://github.com/wso2-ballerina/module-mongodb/releases">here</a>, and install it using the installation script.</p><p>Now I assume you have a MongoDB Atlas account. Its quick and easy to create one. Visit their <a href="https://www.mongodb.com/cloud/atlas">website</a> and create a free account if you don’t have one.</p><p>Then, make sure to add your IP into the whitelist in your MongoDB atlas cloud configuration. There is an option which detects your public IP and adds it, as well.</p><p>Also you’ll have to create a user as well. The user interface is quite intuitive. I don’t think you need instructions for that. :)</p><p>Now you should be able to view your clusters as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hzYtiiwU3Z7JClXUwYwbWQ.png" /></figure><p>Now we want to get the connection string.</p><p>To do that,</p><ol><li>Click on the <em>connect</em> button.</li><li>Then you will see the following UI. Click on <em>Connect Your Application </em>option.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*iab6tdT8qGTkUa-S6jhtaA.png" /></figure><p>3. Then you’ll see the UI below. There will be two options for the connection string. You can use either of them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*4rBM45sUVWQdUksvqpdUEQ.png" /></figure><p>Now you can try out the following Ballerina program which demonstrates creating the endpoint and performing all available operations provided by the WSO2 MongoDB package.</p><p><strong><em>Note:</em></strong><em> WSO2 MongoDB package allows you to either connect with direct URL string or by filling in required properties (host, port,.. etc) separately. The example demonstrates both.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd9755bbc7d5babbfd62f9e84cb6ff0c/href">https://medium.com/media/fd9755bbc7d5babbfd62f9e84cb6ff0c/href</a></iframe><p>This program inserts 3 documents to the collection “Books”, queries for them, and deletes one of them. So after running the program, you should be able to see two documents being inserted in your MongoDB Atlas cluster as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*monEU9XXjKNnLmWGkj5dxQ.png" /></figure><p>That’s about it. Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8fd46f168fb6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ballerina-techblog/lets-connect-to-mongodb-atlas-with-ballerina-8fd46f168fb6">Let’s connect to MongoDB Atlas with Ballerina</a> was originally published in <a href="https://medium.com/ballerina-techblog">Ballerina Swan Lake Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Ballerina] Database connection pool exhausted?]]></title>
            <link>https://medium.com/ballerina-techblog/ballerina-database-connection-pool-exhausted-738e5cfba4be?source=rss-2b16995fc97------2</link>
            <guid isPermaLink="false">https://medium.com/p/738e5cfba4be</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[ballerinalang]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[table]]></category>
            <dc:creator><![CDATA[Manuri Amaya Perera]]></dc:creator>
            <pubDate>Sat, 27 Oct 2018 07:41:46 GMT</pubDate>
            <atom:updated>2019-02-13T06:24:26.357Z</atom:updated>
            <content:encoded><![CDATA[<p>You just started playing around with Ballerina, the new kid in town, and thought let’s see how good she is with databases. Somewhere in the middle you figured out that your connection pool gets exhausted. I’m going to list down a some reasons that could have caused this issue!</p><p>First, I’m going to assume you have, <strong>Connection pool size of the database itself and the ballerina database are set to meet the needs</strong>. This article is only about how you could have caused connection leaks due to the lack of best practices in the ballerina code itself.</p><p>First, the culprit is almost always a table returned by a select action or a call action! It can never be an update action.</p><ol><li>Do you not fully iterate the table?</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48d6758765e1036c263ce8a3b8ac865c/href">https://medium.com/media/48d6758765e1036c263ce8a3b8ac865c/href</a></iframe><p>2. Are you having a break statement in the middle of an iteration?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0d9046f713da104fc965b2821292d899/href">https://medium.com/media/0d9046f713da104fc965b2821292d899/href</a></iframe><p>2. Are you returning from a function in the middle of an iteration?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6834a4e88536f191e20e7483d642dec0/href">https://medium.com/media/6834a4e88536f191e20e7483d642dec0/href</a></iframe><p>These are possible scenarios that could have caused the connection pool exhaustion. Let me explain why.</p><p>When you obtain a table from a select/call operation, the complete result set will not be loaded to memory. The table just keeps a pointer to the database result set. Records will be retrieved on demand. This is because ballerina treats streaming behavior as a first class citizen. <strong>Therefore, connection will be closed when the table is fully iterated or “close” function is called on the table explicitly!</strong></p><p>So, in each of the above mentioned scenarios, table is neither fully iterated or explicitly closed, causing a connection leak.</p><p>Now I guess its obvious to you how to fix this.</p><p>You have to either,</p><ol><li>Fully iterate the table</li></ol><p>Or,</p><p>2. Close the table explicitly before you return in the middle of an iteration, break etc.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=738e5cfba4be" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ballerina-techblog/ballerina-database-connection-pool-exhausted-738e5cfba4be">[Ballerina] Database connection pool exhausted?</a> was originally published in <a href="https://medium.com/ballerina-techblog">Ballerina Swan Lake Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[“select” iterable operation on Ballerina tables]]></title>
            <link>https://medium.com/ballerina-techblog/example-of-select-iterable-operation-on-ballerina-tables-91f46d408597?source=rss-2b16995fc97------2</link>
            <guid isPermaLink="false">https://medium.com/p/91f46d408597</guid>
            <category><![CDATA[table]]></category>
            <category><![CDATA[ballerina]]></category>
            <category><![CDATA[ballerinalang]]></category>
            <category><![CDATA[iterables]]></category>
            <dc:creator><![CDATA[Manuri Amaya Perera]]></dc:creator>
            <pubDate>Mon, 13 Aug 2018 11:10:53 GMT</pubDate>
            <atom:updated>2019-02-13T06:24:14.305Z</atom:updated>
            <content:encoded><![CDATA[<p>In Ballerina programming language, we have these <em>iterable operations </em>that you can perform on iterable collections such as arrays, maps and tables. One of the iterable operations available on table type is <em>select </em>operation. Please don’t confuse this <em>select </em>iterable operation with the Ballerina JDBC client’s select operation. This is a different one!</p><p>Let me explain what select iterable operation does.</p><p>Assume you have a table constrained with “Person” type. Here is the Ballerina record type for “Person”.</p><pre><strong>type </strong>Person <strong>record </strong>{<br>    <strong>int </strong>id,<br>    <strong>float </strong>salary,<br>    <strong>string </strong>name,<br>};</pre><p>And you have another type “Salary”.</p><pre><strong>type </strong>Salary <strong>record </strong>{<br>    <strong>int </strong>id,<br>    <strong>float </strong>salary,<br>};</pre><p>Also, you have following function which would output a “Salary” record given a “Person” record!</p><pre><strong>function </strong>getSalary(Person p) <strong>returns </strong>Salary {<br>    Salary s = { id: p.id, salary: p.salary };<br>    <strong>return </strong>s;<br>}</pre><p>If you want to get a “Salary” table which contains a record for each “Person” in the Person table, you’d have to iterate the Person table and call the above function on each Person record and add it to a new table like below.</p><pre><strong>table</strong>&lt;Salary&gt; salaryTable;<br><strong>foreach </strong>person <strong>in </strong>personTable {<br>    _ = salaryTable.add(getSalary(person));<br>}</pre><p><strong>But wait! Ballerina provides a shortcut for this! That is <em>select </em>iterable operation.</strong></p><p>You can simple do like follows.</p><pre><strong>table</strong>&lt;Salary&gt; salaries = dt.select(getSalary);</pre><p>Saved a few lines of code, didn’t we?</p><p>For the people who want to copy paste a program and see it running, I have put the complete example below that you can simply run! Enjoy!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8632fdfeacdbe4912eee3ba83ff0ff46/href">https://medium.com/media/8632fdfeacdbe4912eee3ba83ff0ff46/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91f46d408597" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ballerina-techblog/example-of-select-iterable-operation-on-ballerina-tables-91f46d408597">“select” iterable operation on Ballerina tables</a> was originally published in <a href="https://medium.com/ballerina-techblog">Ballerina Swan Lake Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[XA transaction example with Ballerina — Oracle and MySQL as resource managers]]></title>
            <link>https://medium.com/ballerina-techblog/xa-transaction-example-with-ballerina-df9221bcf664?source=rss-2b16995fc97------2</link>
            <guid isPermaLink="false">https://medium.com/p/df9221bcf664</guid>
            <category><![CDATA[oracle-database]]></category>
            <category><![CDATA[ballerinalang]]></category>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[ax]]></category>
            <category><![CDATA[transactions]]></category>
            <dc:creator><![CDATA[Manuri Amaya Perera]]></dc:creator>
            <pubDate>Mon, 13 Aug 2018 10:33:24 GMT</pubDate>
            <atom:updated>2019-02-15T06:05:58.138Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s write a Ballerina program that demonstrates performing an XA transaction.</p><p>We have two resource managers, a mysql database and an Oracle database. Here we have two functions to demonstrate a successful transaction and a failing one.</p><p>Here goes the program!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f4b901d66e9b7d4685a917559d8e367/href">https://medium.com/media/0f4b901d66e9b7d4685a917559d8e367/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df9221bcf664" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ballerina-techblog/xa-transaction-example-with-ballerina-df9221bcf664">XA transaction example with Ballerina — Oracle and MySQL as resource managers</a> was originally published in <a href="https://medium.com/ballerina-techblog">Ballerina Swan Lake Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using a Ballerina table as a proxy to an actual database table]]></title>
            <link>https://medium.com/@Manuri/using-a-ballerina-table-as-a-proxy-to-an-actual-database-table-48024792a434?source=rss-2b16995fc97------2</link>
            <guid isPermaLink="false">https://medium.com/p/48024792a434</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[ballerina]]></category>
            <category><![CDATA[ballerinalang]]></category>
            <dc:creator><![CDATA[Manuri Amaya Perera]]></dc:creator>
            <pubDate>Sun, 12 Aug 2018 10:44:34 GMT</pubDate>
            <atom:updated>2018-12-01T13:47:43.593Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>getProxyTable operation has been removed from SQL client starting from Ballerina 0.982.0. So this article is not valid for newer versions.</em></strong></p><p>In Ballerina language there is a type called <em>table. </em>Table type is analogous to a database table. One use case of these tables is acting as a proxy for an actual database table. This is an operation available in Ballerina generic jdbc client and other database specific jdbc clients such as mysql and h2 clients.</p><p>The operation is <em>getProxyTable.</em></p><p>So let’s write a Ballerina program that creates a “proxy” table for an actual database table, inserts some data to it and iterates the database table through the Ballerina table!</p><p>Here goes the program.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2b2da1ce4fdcc1b053b53c8e7c2270c/href">https://medium.com/media/e2b2da1ce4fdcc1b053b53c8e7c2270c/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=48024792a434" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interact with a Postgresql database with Ballerina!]]></title>
            <link>https://medium.com/ballerina-techblog/interact-with-a-postgresql-database-with-ballerina-301fd5bc2c01?source=rss-2b16995fc97------2</link>
            <guid isPermaLink="false">https://medium.com/p/301fd5bc2c01</guid>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[ballerina]]></category>
            <category><![CDATA[ballerinalang]]></category>
            <dc:creator><![CDATA[Manuri Amaya Perera]]></dc:creator>
            <pubDate>Sun, 12 Aug 2018 08:38:37 GMT</pubDate>
            <atom:updated>2019-02-15T06:05:40.473Z</atom:updated>
            <content:encoded><![CDATA[<p>We are going to try out a simple example of interacting with a postgresql database with Ballerina programming language.</p><ol><li>First you need to have postgresql installed.</li><li>Also download and install Ballerina 0.981.0</li><li>Download the <a href="https://jdbc.postgresql.org/download.html">postgresql driver</a> (I used the version 42.2.1)</li></ol><p>Now connect to your postgresql server and create a database called “customerdb”. That is the one we are going to connect through our Ballerina program.</p><p>Here goes the Ballerina program. We are simply creating a table using the Ballerina jdbc client, then insert a record to the table and retrieve the data from that table and iterate!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/46a8ec2012dbf69c82f08709224acf02/href">https://medium.com/media/46a8ec2012dbf69c82f08709224acf02/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=301fd5bc2c01" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ballerina-techblog/interact-with-a-postgresql-database-with-ballerina-301fd5bc2c01">Interact with a Postgresql database with Ballerina!</a> was originally published in <a href="https://medium.com/ballerina-techblog">Ballerina Swan Lake Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Oracle RefCursor Example with Ballerina]]></title>
            <link>https://medium.com/ballerina-techblog/oracle-refcursor-example-with-ballerina-1448cc3aef11?source=rss-2b16995fc97------2</link>
            <guid isPermaLink="false">https://medium.com/p/1448cc3aef11</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ballerinalang]]></category>
            <category><![CDATA[ballerina]]></category>
            <category><![CDATA[oracle]]></category>
            <dc:creator><![CDATA[Manuri Amaya Perera]]></dc:creator>
            <pubDate>Sun, 12 Aug 2018 04:38:51 GMT</pubDate>
            <atom:updated>2019-03-20T08:28:26.060Z</atom:updated>
            <content:encoded><![CDATA[<p>We are going to try out a simple example of how to call a stored procedure in Oracle which has a refcursor OUT parameter, with Ballerina programming language.</p><p>Following are the prerequisites.</p><ol><li>Have Oracle installed. I used 11g.</li><li>Install Ballerina 0.981.0.</li><li>Copy Oracle driver (ojdbc6.jar) to ${BALLERINA_HOME}/bre/lib/</li></ol><p>First, let’s look at the stored procedure.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7322ce69cac037efa3d8d68602639bd/href">https://medium.com/media/a7322ce69cac037efa3d8d68602639bd/href</a></iframe><p>This stored procedure simply takes in a parameter of <em>NUMBER</em> type and returns a refcursor for the result of a select query called on the following table.</p><p>Hope the above stored procedure is simple enough!</p><p>Let’s create a table.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e468de93536e38577d31049e32a1f7a/href">https://medium.com/media/8e468de93536e38577d31049e32a1f7a/href</a></iframe><p>Here goes the Ballerina program to call the above mentioned stored procedure and iterate the results and print them to console.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/91c392bd1f53ca6f1a3fa790a5e2521c/href">https://medium.com/media/91c392bd1f53ca6f1a3fa790a5e2521c/href</a></iframe><p>When you run this program as follows,</p><p><em>ballerina run refcursor-sample.bal</em></p><p>You should see a result similar to below. Please note that you should have some data inserted to your table corresponding to the SQL query.</p><p><em>1.0|Jim|Young|217.5</em></p><p>So, that is it!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1448cc3aef11" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ballerina-techblog/oracle-refcursor-example-with-ballerina-1448cc3aef11">Oracle RefCursor Example with Ballerina</a> was originally published in <a href="https://medium.com/ballerina-techblog">Ballerina Swan Lake Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Oracle PL/SQL example with Ballerina]]></title>
            <link>https://medium.com/ballerina-techblog/oracle-pl-sql-example-with-ballerina-b978eb8a768?source=rss-2b16995fc97------2</link>
            <guid isPermaLink="false">https://medium.com/p/b978eb8a768</guid>
            <category><![CDATA[oracle]]></category>
            <category><![CDATA[plsql]]></category>
            <category><![CDATA[ballerina]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[ballerinalang]]></category>
            <dc:creator><![CDATA[Manuri Amaya Perera]]></dc:creator>
            <pubDate>Thu, 09 Aug 2018 07:59:31 GMT</pubDate>
            <atom:updated>2019-02-15T06:06:52.070Z</atom:updated>
            <content:encoded><![CDATA[<p>Ok, we are going write a simple HTTP service with Ballerina that exposes stored procedures/functions in an Oracle PL/SQL package!</p><ol><li>First, let’s get Oracle set up. I simply followed [1] and got a docker container with oracle 11g running.</li><li>Then installed SQLPlus with the help of [2]. Then connected to my oracle instance in the docker<br>container with the following command.<br><em>sqlplus system/oracle@localhost:49161/xe</em></li><li>Now we need to get Ballerina installed as well. You can download Ballerina from [3].</li></ol><p>Now let’s create a PL/SQL package.</p><p>Connect to the Oracle instance with SQLPlus as I have mentioned above and run the following statements.</p><p>Here we are first declaring a package. This package has 2 functions and one procedure.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d681bcb8eaaf5d4a58ff100d7cca6b7c/href">https://medium.com/media/d681bcb8eaaf5d4a58ff100d7cca6b7c/href</a></iframe><p>Now we are going to define the functions/procedures in the package.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11e6c12ed63258ae0f6b01c2c75eb973/href">https://medium.com/media/11e6c12ed63258ae0f6b01c2c75eb973/href</a></iframe><p>Following is the table used in the above procedures/functions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5f7c6aacd9c9d73deabf9e904de9be5c/href">https://medium.com/media/5f7c6aacd9c9d73deabf9e904de9be5c/href</a></iframe><p>Here is the ballerina program.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e19b5967762689969fc19b53e6b6dc7/href">https://medium.com/media/6e19b5967762689969fc19b53e6b6dc7/href</a></iframe><p>Now start the Ballerina service with the following command.</p><blockquote>ballerina run oracle_plsql_service.bal</blockquote><p>If service was successfully started you should see an output similar to the following.</p><blockquote>ballerina: initiating service(s) in ‘oracle_plsql_service.bal’<br>ballerina: started HTTP/WS endpoint 0.0.0.0:9090</blockquote><p>Following are sample cURL requests you can send to this service.</p><p><strong>Request:</strong></p><blockquote>curl -v <a href="http://localhost:9090/dataService/getInfoById/2">http://localhost:9090/dataService/getInfoById/2</a></blockquote><p><strong>Output:</strong></p><blockquote>&lt;results&gt;&lt;result&gt;&lt;first_name&gt;Manuri&lt;/first_name&gt;&lt;last_name&gt;Perera&lt;/last_name&gt;&lt;id&gt;2.0&lt;/id&gt;&lt;salary&gt;20.0&lt;/salary&gt;&lt;/result&gt;&lt;/results&gt;</blockquote><p><strong>Request:</strong></p><blockquote>curl -v <a href="http://localhost:9090/dataService/getSalary/2">http://localhost:9090/dataService/getSalary/2</a></blockquote><p><strong>Output:</strong></p><blockquote>&lt;Salary&gt;&lt;id&gt;2&lt;/id&gt;&lt;value&gt;20.0&lt;/value&gt;&lt;/Salary&gt;</blockquote><p><strong>Request:</strong></p><blockquote>curl -v <a href="http://localhost:9090/dataService/adjustSalary/1/20">http://localhost:9090/dataService/adjustSalary/1/20</a></blockquote><p><strong>Output:</strong></p><blockquote>&lt;Salary&gt;&lt;id&gt;2&lt;/id&gt;&lt;value&gt;24.0&lt;/value&gt;&lt;/Salary&gt;</blockquote><p>[1] <a href="https://tuhrig.de/3-ways-of-installing-oracle-xe-11g-on-ubuntu/">https://tuhrig.de/3-ways-of-installing-oracle-xe-11g-on-ubuntu/</a><br>[2] <a href="https://gm.matias.ph/internet-technology/linux-unix/running-oracles-sql-plus-in-linux-ubuntu/">https://gm.matias.ph/internet-technology/linux-unix/running-oracles-sql-plus-in-linux-ubuntu/</a><br>[3] <a href="https://ballerina.io/downloads/">https://ballerina.io/downloads/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b978eb8a768" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ballerina-techblog/oracle-pl-sql-example-with-ballerina-b978eb8a768">Oracle PL/SQL example with Ballerina</a> was originally published in <a href="https://medium.com/ballerina-techblog">Ballerina Swan Lake Tech Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>