martedì 11 ottobre 2016

Oracle Tip: executing SQL scripts in SQL Developer

One common problem with SQL Developer is executing huge SQL scripts (i.e. INSERT statements from the export of a big table).
Typically you will get the following error when trying to open the file: 

which is caused by an OutOfMemoryError of the Java Heap space.

One convenient way to execute .sql without having to open the script in the SQL Developer editor is to configure the default path for scripts.
Go to Tools -> Preferences->Database->Worksheet:

and select the path where you want to place the SQL scripts to execute.
Then, go to the SQL Developer editor and simply use the @ command to reference and execute the script.

lunedì 10 ottobre 2016

ODI Tip: Generating flat files with spaces in column names

I had a requirement of generating a .csv file with header out of a database table.
I had created the model as follows:
  • File Format: Delimited
  • Record Separator: Unix  
  • Field Separator: , (comma)
In the interface, I had placed the file as Target Datasource and used 'IKM SQL to File Append' with the following options:

Unfortunately, the header columns were truncated at the first space and adding double quotes did not help. The column header were all truncated after the first space found.
After investigating, I came to the conclusion that there is was no quick or easy way to deal with spaces. I guess the only way is creating a custom version of the IKM.
Therefore, since I have very little time, I have replaced the spaces with underscores and added a OdiOSCommand in the package to replace the underscores with spaces in the output file.

ODIOSCommand is a more flexible version of OSCommand and allows you to invoke a sed command to do the replacement in place (-i) of the underscores with spaces.

sed -i 's/_/ /g' <filename>

lunedì 18 luglio 2016

Oracle Tip: Exception getObjectName("R", "OBI_EXEC_SESS_<$=Y$>", "D")

When running OBIA Load Plan, today I got into the following error when running SIL_DomainGeneral_CM_Source_Load scenario: ODI-17517: Error during task interpretation.
 Task: 6
java.lang.Exception: The application script threw an exception: Exception getObjectName("R", "OBI_EXEC_SESS_<$=Y$>", "D") :  BSF info: Run Alter Session Commands-SRC (DB Link) at line: 0 column: columnNo

The solution to this error is given in Doc ID 1948605.1 from Oracle Support.
You should connect to ODI Physical Architecture in ODI Topology and check that BIAPPS_BIACOMP has got a Default Schema defined (and that connectivity is in place). If there is no Physical Schema defined, then check the option. 


If this does not solve the problem, check BIAPPS DWH Physical Connection. Make sure that at least one of the physical schemas is marked as Default Schema.

Somehow during migration activities, we lost the selection on one of them.

lunedì 29 febbraio 2016

Configuring PGP Keys in GNU Private Guard

Imagine you are receiving a PGP encrypted file from a third-party. 
The file has been encrypted using the customer's Public Key and now you have to decrypt it in a separate server where Gnu PG is installed. 
The first thing you need to do is to import the keys so they can be used to decrypt the message.
The following command is used to import the Public Key: 

gpg --import newkey.txt
If a valid Public Key is given, this is how the command output should look like: 

bash-4.1$ gpg2 --import newkey.txt
gpg: key xxxxxx: "Public Key Description <>" not changed
gpg: Total number processed: 1
gpg:              unchanged: 1

To import the Private Key, use the following command: 

gpg --allow-secret-key-import --import newpriv_key.txt
To check if keys have been imported correctly, you can use the following command:

bash-4.1$ gpg --list-keys
pub   2048R/xxxxxxx 2016-02-17 [expires: 2019-02-16]
uid                 Public Key Description <>

sub   2048R/xxxxxxx 2016-02-17 [expires: 2019-02-16]

The Private Key provided has got a passphrase. So if you want to decrypt a sample file that has been encrypted using the associated Public Key, you should use the following command.

bash-4.1$ echo <passphrase>|gpg --output test.txt --batch --passphrase-fd 0 --decrypt test.gpg
gpg: encrypted with 2048-bit RSA key, ID
XXX450C8 , created 2016-02-17
Public Key Description <>"
bash-4.1$ more test.txt
Hello World!!!


If you are getting an error when passing the passphrase, try setting up the following variables: 

export GPG_TTY=`tty` 

By doing this, I was able to decrypt the message successfully.

martedì 26 gennaio 2016

Automate DOS commands - Ping example

Imagine you have been given the lovely task of finding out the IP address of more than 40 servers. Do you really want to do it manually? Definitely I do not.
I have created a script and, even if I have to admit that it took me almost more time to write it than doing the task manually, I hope this can save someone's else time.
The script I have written looks like this:

ping -n 1 <ServerName1> | for /F "tokens=*" %%a in ('findstr Reply') do @echo
ping -n 1
<ServerName2> | for /f "tokens=*" %%a in ('findstr Reply') do @echo <ServerName2>:%%a

The option "-n 1" is used to define how many times the server is pinged. One time is enough to get the following output:

Pinging <ServerName1> [] with 32 bytes of data:
Reply from bytes=32 time=45ms TTL=59
Ping statistics for
    Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 45ms, Maximum = 45ms, Average = 45ms

The second part of the command parses the output of the ping command looking for a string starting with 'Reply' and prints the results.
@ECHO OFF is used to prevent the script to print the DOS command in the output.
Here is an example of output file:

<ServerName1>:Reply from bytes=32 time=18ms TTL=59 <ServerName2>:Reply from bytes=32 time=19ms TTL=59

I have decided to separate the server name from the 'Reply' string using a semicolon, but it is mainly because this way I can treat the output as a simple semicolon-delimited file.

martedì 10 novembre 2015

Changing caption of Embedded Object in MS Word

Recently I have spent a lot of time writing functional documents, which translates into producing tons of MS Word pages and Excel Spreadsheets. And since everybody knows how boring it is, the best thing you can do is re-use docs you have already written. Although it can save you a considerable amount of time, it could be very annoying having an attached spreadsheet with a caption that reminds everybody that you are being lazy.
To change it,  right-click on the Object and select Convert option:

Then select "Change Icon" and change the Caption to the one you want. Be aware that even if it looks greyed-out, you can still edit the Caption. God bless MS!

venerdì 30 ottobre 2015

Another week in the life of a cystinuric

It's a matter of not surrending. It's a matter of not admitting that this horrible disease is sucking my whole life out of me. 
I cannot work, I cannot enjoy being out because of the fear of the unpredictable pain, I am soaked in fear. 
I hate the person I am now. I do not resemble to the person I used to be. After three surgeries, uncountable infections, stents, pain killers and every possible kind of medicine, doctors, urologists, nephrologists, it is getting harder and harder to go on.
If I could put on a scale all the pain I have been through since I was a kid, it would explode. And the worst thing is that there is no reward. You won't get any prize for being strong. And asking "Why me?" is totally pointless. It won't go away.
The only thing you can think about is the pain to stop. Nothing else. There is no energy or space for anything else. Nobody deserves something like this. Nobody.