<?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 Javier de la Torre on Medium]]></title>
        <description><![CDATA[Stories by Javier de la Torre on Medium]]></description>
        <link>https://medium.com/@javidelatorre?source=rss-7a69539c8ba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*XWsv8srQd30e3SOX</url>
            <title>Stories by Javier de la Torre on Medium</title>
            <link>https://medium.com/@javidelatorre?source=rss-7a69539c8ba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 11:42:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@javidelatorre/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[Mastering 23c Developer free: SQL Domains and JSON Schema]]></title>
            <link>https://medium.com/@javidelatorre/mastering-23c-developer-free-sql-domains-and-json-schema-3611dbe879b9?source=rss-7a69539c8ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/3611dbe879b9</guid>
            <dc:creator><![CDATA[Javier de la Torre]]></dc:creator>
            <pubDate>Tue, 11 Apr 2023 15:26:18 GMT</pubDate>
            <atom:updated>2023-05-03T09:28:28.426Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*loqdZ5Hp6WOP8gaqpTXEBQ.png" /></figure><p>Oracle just released the free version of the Oracle Database 23c for developers. This version provides early access to great features that simplifies the development of new data-driven applications. In this blog we are going to cover a few of them. If you are interested to have a look into the announcement, you can read it <a href="https://www.oracle.com/uk/news/announcement/oracle-database-23c-free-developer-release-2023-04-03/">here</a>.</p><p>The first feature we are going to explain is the SQL Domains. In a SQL Domain we define properties and constraints. This allows developers to better understand how data is used and improves overall data quality.</p><p>Let’s start with an easy example. We want to create a table with customer information. This customer will be oriented for the marketing department and we want to store some info about them and a discount voucher. We are going to define a constraint to limit the amount voucher, how do we want to display and order it and finally some annotations.</p><p>Annotations is another great capability which allows developer to store metadata directly with the data. In this case we are going to store some information about the purpose of this voucher:</p><pre>CREATE DOMAIN  voucher AS  Number<br>DEFAULT ON NULL 0<br>CONSTRAINT voucher_limits CHECK (voucher &gt; = 0 and voucher &lt;=500) ENABLE<br>DISPLAY TO_CHAR(voucher, &#39;$999.99&#39;)  <br>ORDER ( -1*voucher) <br>ANNOTATIONS (properties &#39;{&quot;Department&quot;: &quot;Marketing&quot;, &quot;Country&quot;: &quot;USA&quot;, &quot;Max Voucher&quot;: &quot;500$&quot; }&#39;);</pre><p>SQL Domains provide great flexibility and we can define any kind of constraint. We are going to create a new domain to be sure that emails inserted into the table have the right email format using regular expressions. Moreover, we are going to define a display property to mask the email:</p><pre>CREATE DOMAIN email_domain as varchar2(100)<br>constraint email_check check (regexp_like (email_domain, &#39;^(\S+)\@(\S+)\.(\S+)$&#39;))<br>DISPLAY &#39;---&#39; || SUBSTR(email_domain, INSTR(email_domain, &#39;@&#39;) );</pre><p>With the two SQL Domains created, we can create a new table containing them:</p><pre>create table customers (<br>  first_name varchar2(100), <br>  last_name varchar2(100),<br>  cust_id number, <br>  customer_voucher number domain voucher, <br>  email varchar2(100) domain email_domain<br>  );</pre><p>We are ready to insert some data:</p><pre>insert into customers values (&#39;John&#39;,&#39;Smith&#39;,1,100,&#39;john.smith@mail.com&#39;);<br>insert into customers values (&#39;Arno&#39;,&#39;Links&#39;,2,50,&#39;arno.links@mail.com&#39;);<br>insert into customers values (&#39;Becky&#39;,&#39;Graham&#39;,3,500,&#39;becky.graham@mail.com&#39;);<br>insert into customers values (&#39;Belinda&#39;,&#39;Dunlop&#39;,4,250,&#39;belinda.dunlop@mail.com&#39;);<br>insert into customers values (&#39;Frank&#39;,&#39;Hardy&#39;,5,0,&#39;frank.hardy@mail.com&#39;);<br>commit;</pre><p>We are going to run a simple query. You can see a new SQL function called <strong>domain_order. </strong>This function returns the domains order expression in which was defined. For the voucher domain we defined a -1. This means we want a descendent order:</p><pre><br>SQL&gt; select first_name,last_name,customer_voucher,email <br>from customers order by domain_order(customer_voucher);<br><br>FIRST_NAME    LAST_NAME       CUSTOMER_VOUCHER EMAIL<br>_____________ ____________ ___________________ __________________________<br>Becky         Graham                       500 becky.graham@mail.com<br>Belinda       Dunlop                       250 belinda.dunlop@mail.com<br>John          Smith                        100 john.smith@mail.com<br>Arno          Links                         50 arno.links@mail.com<br>Frank         Hardy                          0 frank.hardy@mail.com<br><br>SQL&gt;</pre><p>If we remove the SQL function, we can see it is ordered ascendant:</p><pre>SQL&gt; select first_name,last_name,customer_voucher,email <br>from customers order by customer_voucher;<br><br>FIRST_NAME    LAST_NAME       CUSTOMER_VOUCHER EMAIL<br>_____________ ____________ ___________________ __________________________<br>Frank         Hardy                          0 frank.hardy@mail.com<br>Arno          Links                         50 arno.links@mail.com<br>John          Smith                        100 john.smith@mail.com<br>Belinda       Dunlop                       250 belinda.dunlop@mail.com<br>Becky         Graham                       500 becky.graham@mail.com</pre><p>But, what happened with our display properties? You need to use the <strong>domain_display</strong> to print the already defined property. The voucher follows the defined pattern and the email has been masked:</p><pre>SQL&gt; select domain_display(customer_voucher),domain_display(email) from customers;<br><br>DOMAIN_DISPLAY(CUSTOMER_VOUCHER)    DOMAIN_DISPLAY(EMAIL)<br>___________________________________ ________________________<br> $100.00                            ---@mail.com<br>  $50.00                            ---@mail.com<br> $500.00                            ---@mail.com<br> $250.00                            ---@mail.com<br>    $.00                            ---@mail.com<br><br>SQL&gt;</pre><p>Oracle already provides many built-in usage domains so is worth it to have a look so you can take advantage of them. You can find the list on the documentation <a href="https://docs.oracle.com/en/database/oracle/oracle-database/23/adfns/registering-application-data-usage-database.html">here</a>, but I’m going to create a table containing phone numbers and a credit card using the existing domains.</p><pre>create table employees (<br>  credit_card credit_card_number_d,<br>  phone phone_number_d<br>  );</pre><p>If you want to query and understand the metadata defined, you can query some dictionary views to find the table which contains annotations:</p><pre>SQL&gt; SELECT * from USER_ANNOTATIONS_USAGE WHERE Object_Name = &#39;CUSTOMERS&#39; AND Object_Type = &#39;TABLE&#39;;<br><br>OBJECT_NAME    OBJECT_TYPE    COLUMN_NAME         DOMAIN_NAME    DOMAIN_OWNER    ANNOTATION_NAME    ANNOTATION_VALUE<br>______________ ______________ ___________________ ______________ _______________ __________________ ________________________________________________________________________<br>CUSTOMERS      TABLE          CUSTOMER_VOUCHER    VOUCHER        TEST            PROPERTIES         {&quot;Department&quot;: &quot;Marketing&quot;, &quot;Country&quot;: &quot;USA&quot;, &quot;Max Voucher&quot;: &quot;500$&quot; }<br><br>SQL&gt;</pre><p>We have seen a good overview of the SQL Domains capabilities, but there are more! We can use them to define JSON schemas! We can validate the structure and type information of your JSON documents.</p><pre>create  domain product_schema as JSON validate using <br>&#39;{<br>    &quot;type&quot;: &quot;object&quot;, <br>    &quot;additionalProperties&quot;:false,<br>    &quot;required&quot;:[&quot;starring&quot;],<br>    &quot;properties&quot;: {<br>    &quot;id&quot;: {&quot;type&quot;: &quot;number&quot;} ,<br>    &quot;type&quot; : {&quot;type&quot;:&quot;string&quot;,&quot;maxLength&quot;: 50},<br>    &quot;title&quot; : {&quot;type&quot;:&quot;string&quot;,&quot;maxLength&quot;: 50},<br>    &quot;format&quot; : {&quot;type&quot;:&quot;string&quot;,&quot;maxLength&quot;: 50},<br>    &quot;condition&quot; : {&quot;type&quot;:&quot;string&quot;,&quot;maxLength&quot;: 50},<br>    &quot;price&quot;: {&quot;type&quot;: &quot;number&quot;},<br>    &quot;comment&quot; : {&quot;type&quot;:&quot;string&quot;,&quot;maxLength&quot;: 50},<br>    &quot;starring&quot; : {&quot;type&quot;:&quot;array&quot;},<br>    &quot;year&quot;: {&quot;type&quot;: &quot;number&quot;} ,<br>    &quot;decade&quot; : {&quot;type&quot;:&quot;string&quot;,&quot;maxLength&quot;: 50}<br>    }<br>    }&#39;;</pre><p>In the product_schema domain you can see the different properties of your JSON schema. We have added to important fields. The first one is <strong>required</strong>. If the starring array is not present, it will raise an error when trying to insert new data. Also we have the <strong>additionalProperties</strong> field, which is not allowing new fields into the JSON.</p><p>Once we have the schema defined, we can create the new table directly:</p><pre>CREATE TABLE products(json_data JSON DOMAIN product_schema);</pre><p>Let’s try the first insert. This one is following the schema so we are not getting any error.</p><pre>insert into products(json_data) values(<br>        &#39;{<br>          &quot;id&quot;: 100,<br>          &quot;type&quot;: &quot;movie&quot;,<br>          &quot;title&quot;: &quot;Coming to America&quot;,<br>          &quot;format&quot;: &quot;DVD&quot;,<br>          &quot;condition&quot;: &quot;acceptable&quot;,<br>          &quot;price&quot;: 5,<br>          &quot;comment&quot;: &quot;DVD in excellent condition, cover is blurred&quot;,<br>          &quot;starring&quot;: [<br>            &quot;Eddie Murphy&quot;,<br>            &quot;Arsenio Hall&quot;,<br>            &quot;James Earl Jones&quot;,<br>            &quot;John Amos&quot;<br>          ],<br>          &quot;year&quot;: 1988,<br>          &quot;decade&quot;: &quot;80s&quot;<br>        }<br>        &#39;);<br>        commit;</pre><p>The next JSON document is missing the starring field. Therefore we are getting an error.</p><pre>insert into products(json_data) values(<br>          &#39;{<br>            &quot;id&quot;: 100,<br>            &quot;type&quot;: &quot;movie&quot;,<br>            &quot;title&quot;: &quot;Coming to America&quot;,<br>            &quot;format&quot;: &quot;DVD&quot;,<br>            &quot;condition&quot;: &quot;acceptable&quot;,<br>            &quot;price&quot;: 5,<br>            &quot;comment&quot;: &quot;DVD in excellent condition, cover is blurred&quot;,<br>            &quot;year&quot;: 1988,<br>            &quot;decade&quot;: &quot;80s&quot;<br>          }<br>          &#39;)<br>Error at Command Line : 1 Column : 13<br>Error report -<br>SQL Error: ORA-40875: JSON schema validation error</pre><p>In this last example we are adding a new field called pages, and also we are getting an error.</p><pre>insert into Products(json_data) values(<br>            &#39;{<br>              &quot;id&quot;: 103,<br>              &quot;pages&quot;: 250,<br>              &quot;title&quot;: &quot;The Thing&quot;,<br>              &quot;type&quot;: &quot;book&quot;,<br>              &quot;condition&quot;: &quot;okay&quot;,<br>              &quot;price&quot;: 2.5,<br>              &quot;author&quot;: &quot;Alan Dean Forster&quot;,<br>              &quot;starring&quot;: [<br>                &quot;Eddie Murphy&quot;,<br>                &quot;Arsenio Hall&quot;,<br>                &quot;James Earl Jones&quot;,<br>                &quot;John Amos&quot;<br>              ],<br>              &quot;year&quot;: 1982,<br>              &quot;decade&quot;: &quot;80s&quot;<br>            }<br>            &#39;)<br>Error at Command Line : 1 Column : 13<br>Error report -<br>SQL Error: ORA-40875: JSON schema validation error</pre><p>In this blog we had covered SQL Domains, annotations and JSON Schemas. If you want to have a deeper look you can find the Oracle Database 23c Developer free doc <a href="https://docs.oracle.com/en/database/oracle/oracle-database/23/index.html">here</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3611dbe879b9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to rotate Oracle Autonomous Wallets with a Grace Period]]></title>
            <link>https://medium.com/@javidelatorre/how-to-rotate-oracle-autonomous-wallets-with-a-grace-period-8cf3a75e2ac6?source=rss-7a69539c8ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/8cf3a75e2ac6</guid>
            <dc:creator><![CDATA[Javier de la Torre]]></dc:creator>
            <pubDate>Wed, 20 Jul 2022 16:32:14 GMT</pubDate>
            <atom:updated>2022-07-20T16:32:14.946Z</atom:updated>
            <content:encoded><![CDATA[<p>Oracle Autonomous Database allows to rotate the wallets with a grace period between 1 hour and 24 hours. Having this grace period, allows you to configure the new wallet without having any downtime in your applications.</p><p>During the grace period, the old wallet and the new wallet are valid. Once the grace period expires, Oracle Autonomous Database automatically invalidate the old wallet. Let’s have a look.</p><p>Let’s consider the following Oracle Autonomous Data Warehouse. First I’m going to download the wallet to connect through the DB Connect button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DJRulEsVT7tpl_1b9UzlIw.png" /></figure><p>Once downloaded, I’m going to use the Cloud Shell to connect.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HdknvfdIuoB8Xe_gCHSjYg.png" /></figure><p>Now I can upload the wallet file into the Cloud Shell. I will connect into my Oracle Autonomous Data Warehouse from there.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mCrekZ8Ta9zqNwqF7qvKmQ.png" /></figure><p>Now we are ready to go! I’m going to create a specific folder to unzip my wallet and I will configure it. Remember to change the sqlnet.ora with the right directory path where the wallet is located.</p><pre>$ mkdir wallet<br>$ mv my_wallet.zip wallet<br>$ cd wallet<br>$ unzip my_wallet.zip<br>$ pwd<br>  /home/javier/wallet</pre><pre>$ vi sqlnet.ora<br>$ export TNS_ADMIN=/home/javier/wallet<br>$ date <br>  Wed Jul 20 09:48:53 UTC 2022</pre><pre>$ sqlplus admin@autonomousdw_medium</pre><pre>SQL*Plus: Release 21.0.0.0.0 - Production on Wed Jul 20 09:48:59 2022</pre><pre>Version 21.6.0.0.0</pre><pre>Copyright (c) 1982, 2022, Oracle.  All rights reserved.</pre><pre>Enter password:</pre><pre>Last Successful login time: Wed Jul 20 2022 09:45:52 +00:00<br>Connected to:</pre><pre>Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production</pre><pre>Version 19.16.0.1.0</pre><pre>SQL&gt;</pre><p>As you can see, I’m able to connect successfully. Observe I had run the command date, so I can check what happens once the grace period is expired. Now let’s rotate the wallet. We can do this from the Database Connection menu.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gbKZPENnoiykh5zE5LcWHg.png" /></figure><p>I’m going to choose a grace period of 1 hour, so we can check what happens after that time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gkP31SNhc7xM4154DUx9pw.png" /></figure><p>Once we click rotate, you still will be able to connect to the Oracle Autonomous Data Warehouse using the same wallet. Let’s see what happens after 1 hour later.</p><pre>$ date</pre><pre>Wed Jul 20 10:54:36 UTC 2022</pre><pre>$ sqlplus admin@autonomousdw_medium</pre><pre>SQL*Plus: Release 21.0.0.0.0 - Production on Wed Jul 20 10:54:39 2022</pre><pre>Version 21.6.0.0.0</pre><pre>Copyright (c) 1982, 2022, Oracle.  All rights reserved.</pre><pre>Enter password:</pre><pre>ERROR:</pre><pre><strong>ORA-12529: TNS:connect request rejected based on current filtering rules</strong></pre><p>As you can see, the wallet has expired and therefore it’s not possible to connect. If you follow the same process again, downloading the new wallet from Database Connection and configuring it, you will be able to connect successfully.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8cf3a75e2ac6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>