Posts

Showing posts from 2017

Keep the APEX builder tab and application tab in the same Firefox window

Image
A long while ago, I switched to using Google Chrome, and I use Firefox usually only to test some feature so I literally have not run the APEX builder in Firefox since version 3.2. However, recently I heard about Firefox having a neat new feature which is called "Containers" and is part of their Test Pilot program, where you can have a set of tabs each with their own cookie/storage/session space - you can read more about the technology here -  https://testpilot.firefox.com/experiments/containers/ . This is good news, because it would allow be to be logged in with different user account simultaneously and thus speeding up testing time. However, much to my surprise, unlike it Chrome when you run the application, it opens the application in a new tab, Firefox opens the application in a new window! I don't particularly like this behaviour, so after some digging I firstly found there is a preference to open new windows in a new tab instead. The bad news is, this seeme

ES6 with SQLcl / JDK9

In JDK 8, the Nashorn engine was still on ES5. With the latest release (JDK9), they have included optional support for ES6, which can be enabled by way of an argument. So, to test out this functionality I will be trying with a new variable/constant construct called `const`. Before developing my script for SQLcl, I sometimes like to use jjs to verify everything. jjs is an interactive shell that invokes the Nashorn engine. So by defualt it uses ES5, so we can write a script like so: jjs> var a = Math.floor(Math.random()*100) * 55 jjs> print (a) 990 jjs> With JDK9, we can invoke this tool with ES6 support via an optional argument `--language` where we can specifiy either es5 or es6. $ jjs --language=es6 jjs> const a = Math.floor(Math.random()*100) * 55 jjs> a = 2 <shell>:1 TypeError: Assignment to constant "a" jjs> print (a); 2695 jjs> The above snippet shows I can use the new `const` construct that is a part of the ES6 spec within the Nas

Setting up Oracle XE in Docker - Lessons Learned

For a little side project I'm working on, I had the need to set up a Docker instance of Oracle. I have read about Docker a while back and understand the general concept - but up until now, I hadn't had much experience with it (other that running the basic hello-world Docker example). So, since I'm about using the free version of the Oracle Database at the moment (Oracle XE), I wanted specifically to build that in a VM. Now, I know that Oracle has a GitHub repository with some sample Docker files - unfortunately, I didn't have success with the Oracle XE version, so it wasn't a bad time to go and build my own. Here are some things I learnt: 1. The default storage location on my Ubuntu system is: /var/lib/docker This is a problem as I'm developing, since the way my disk is set up, the root partition soon fills up. 2. You can change the location that images are stored, by creating a json file: /etc/docker/daemon.json. In here, you will want an entry &quo

Bulk loading a template APEX application in a single workspace

I recently had a need to import the same application multiple times - 30+, so each person accessing the workspace could use their own application to play around with. And the user list was supplied to me in the format of an Excel spreadsheet. So, first in the Excel sheet, I had to make a new column to derive some sort of unique value - what better than the first letter of their first name and the surname. Like John Smith -> JSMITH. So, first I made a new column with the value as a formula, which was: =LEFT(A2,1). That would give me "J" for "John. Then, for the actual account ID I come up with the formula =UPPER(CONCAT(C2, B2)) Where C2=J and B2 = SMITH, giving me JSMITH. With that list, I can copy it over to my trusty text editor in order to manipulate to create an array. The first part I wanted to do was create all the users, so for that I can use raw PL/SQL, and come up with a block of code like so: declare type t_users is table of varchar2(200)

Report row buttons firing a dynamic action

Image
A lot of the time on reports of data, we'll define a link column, and specify an image which is the beloved pencil icon. Which is good and all, but looking in the Sample Database Application (packaged application), they have taken a different approach to style links - a button that stretches the width of it's containing cell. So, the UI ends up looking like so: So, is this done? Well first, you define a new column for the placeholder. Suppose I want my link column to be Report, I define an extra column in my query: , 'Report' report_link Then I need to go to my new column's attributes, and change the column type to a link. And, in the link attributes, set the text to what you want displayed. Here, I'm just going to display the value of the new column and point to my desired page. So I set the target page, then also the Link text as #REPORT_LINK#. At this point the report will just show link text, as we expect. So, then to replicate t

Custom workflow to download or upload specific Google Drive files

I had an interest in downloading and uploading a specific file into my Google Drive at certain timing points. For examples sake, let's call the files "Designs.cad". There is a command line project on GitHub which is Go based. So if you have Go installed, it is just a matter of running: go get github.com/prasmussen/gdrive This will download from source, so if you don't want to do this or if you don't have Go installed (you should - there are lots of great go projects), you can see a list of releases on the project page -  https://github.com/prasmussen/gdrive - which you can download and place in your system somewhere, with the command becoming "gdrive". When you first install it, you will need to authenticate your account. Running any command will prompt you to go to a URL to get an authorization code and paste in back on your console. So for example, if I run: gdrive list Which is designed to list files in my Drive. After running the command,

Converting a physical machine for use in VirtualBox

Image
I recently had an interest in converting a physical machine (Windows) I have into a virtualised environment. For my personal Virtual needs, I tend to use and favour VirtualBox - so my end goal is to have the system running in VirtualBox. A quick google with these keywords reveals this VirtualBox article:  https://www.virtualbox.org/wiki/Migrate_Windows . However, this talks about Windows XP, and then one of the software it references is 10 years old. And for some extra context, Windows XP was first released in 2001 and the last release (SP3) in 2008. Ok, so I'm deciding not to go down that path. Putting aside the previous article, I happen to know there are two solutions that support converting a physical machine. VMWare Microsoft (Disk2vhd) So, I will go with the VMWare option for this article/guide. The software is found over at:  https://www.vmware.com/ca/products/converter.html . So, I download and install the software (note, you will need a VMWare account in order to

Using the Oracle node driver on Windows

Image
I have a pretty fresh installation of Windows, and I wanted to get going with the Node driver on that system. I know from memory it requires the Oracle client, so the first thing I do is go and install the Oracle instant client. So, I head over to:  http://www.oracle.com/technetwork/topics/winx64soft-089540.html And what I normally stick to is three packages: Basic (Light) SQL*Plus SDK With those downloaded I then unzip them all - as long as you downloaded to the same directory, each should hopefully unzip into a single folder: instantclient_12_2 (depending on the version you grabbed, of course). After I unzip all those, I moved the instantclient folder to a more convenient location. So, I just place it at: C:\instantclient_12_2 The next step after that is to set up some environment variables. First, you will want to update your path so that `sql*plus` is on it. So, add a new entry on your path pointing to: C:\instantclient_12_2 Usually, you will want to set your ORACL

SQLcl scripting and npm modules

Node, or rather npm, has a huge collection of submitted modules! And if you've been using SQLcl to connect with the database, you should know it has scriptable ability where you can for example run JavaScript code and Java APIs. So the question is, how do we get the script to pick up node modules? During my research, I found a few suggested methods: J2V8 Project Avatar jvm-npm I didn't try the first two methods, but have had success using the third (jvm-npm). This is a library with the source code hosted over on GitHub -  https://github.com/nodyn/jvm-npm. At this point, it's worth noting - not everything will work, as it does not include the full NodeJS API.  So, first step to do is you'll probably want to host that library somewhere in your project - in my example, which I will provide the link to at the end of the article, I place it at ./lib/jvm-npm.js. Worth mentioning, you can also source this over http in your script, but probably best to keep a l

Loading data from a web service. An alternate approach

I was recently working on a project where my client had just implemented a new system, and now they wanted to utilise the provided web services on this platform for some more reporting that wasn't provided out of the box. Being we use APEX, we had the nice APEX_WEB_SERVICE API to use - which made things nice and simple, but before that we needed to perform a couple of extra steps, which is required each time you want to pull data over the web from another domain. It's actually, I feel, too complicated to get going - but I understand these restrictions are in place to keep systems nice and secure. In a nut shell, we should be dealing with resources secured with some certificates - so we need to create both an ACL to the resource followed by creating a wallet with all the certificates the site uses. After that, we are good to go - until some time down the track when the service updates there certificates, then we once again need to update our wallet with the sites certificate

Debugging those JavaScripts

Image
So, you have some code that is playing up, and you want to debug them. We have a few options depending on the situation we are in. 1. Debug APEX/web app in Chrome I primarily use Google Chrome, so will be focusing on using that browser to debug. The next thing we want to do is enable a break point so that the execution will pause in you can inspect variables and step over the code line by line. Typically, in the developer tools you will want to navigate to the sources tab, find your script and add the break point. In the case of inline, I found the following interesting behaviour (unsure if its a buggy browser version or what). When I run the page for the first time, and open the developer tools, trying to open the page source will result in an empty document. However, if I re-run the page with the developer tools open, the full page source will be displayed. Another neat trick that I discovered, is that you can map inline code to a "dummy" source file, as d

(My current) Atom editor Oracle plugins

Image
If you are an Oracle developer and use Atom text editor, here are some extensions that may make your development experience more pleasant. language-oracle build-oracle autocomplete-oracle (experimental/early) plsql-block language-oracle This extension aims to provide the syntax highlighting into Atom. It was converted from a text mate bundle back in October 2015, with a few little tweaks here and there since. To install, open your settings dialog (ctrl+,), go to the Install node and search "language-oracle". The package should come up as the first result, so hit the install button. (alternatively, from the command line, run: `apm install language-oracle`) After it's installed, your favourite extensions for Oracle DDL should now be picked up as PL/SQL (Oracle) in the status bar and the keywords and package references should be appropriately styled. build-oracle You may recall I blogged about compiling Oracle code back in September 2